iam正在运行一个selenium脚本,并不断出现上述错误。这是代码:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class WhatsappTest {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\Users\PC-Name\Documents\selenium jars\chromedriver_win32\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=C:\Users\PC-Name\AppData\Local\Google\Chrome\User Data");
// options.addArguments("--no-sandbox");
// options.addArguments("--disable-dev-shm-usage");
WebDriver driver = new ChromeDriver(options);
//Puts an Implicit wait, Will wait for 10 seconds before throwing exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//Maximize the browser
driver.manage().window().maximize();
//Launch website
driver.navigate().to("https://www.facebook.com/");
System.out.println(driver.getTitle());
driver.close();
}
}
所以代码中的注释行对我不起作用。当我添加这一行时,我总是会收到这个错误:
options.addArguments("user-data-dir=C:\Users\Manish\AppData\Local\Google\Chrome\User Data");
并且代码在不添加以上行的情况下工作良好。
以下是关于错误的更多信息:
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:Program Files (x86)GoogleChromeApplicationchrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
系统信息:Windows 7 SP-1 64位
Chrome信息:版本71.0.3578.98(官方版本((64位(
Java版本:10.0.1
请帮我做这个。
您的路径无效。。。很可能是因为空间。试试这个:
options.addArguments("user-data-
dir=C:\Users\Manish\AppData\Local\Google\Chrome\User_Data");
如果这不起作用,则会有其他标记用于替换空间。