【发布时间】:2019-05-15 01:01:00
【问题描述】:
我正在运行 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)\Google\Chrome\Application\chrome.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
请帮帮我。
【问题讨论】:
-
@DebanjanB 该线程中的任何解决方案都不适合我。已经检查然后发布了这个问题。那么您能否删除重复标记,或者如果可能,请帮助我解决此错误。
-
您能否更新问题以说明此问题与带有 dup 标记的问题有何不同?在这里,我们大多数人都是开发人员,并希望保留DRY。见:How do I do X?
标签: java selenium selenium-chromedriver