我正在尝试使用URL启动chrome,浏览器启动,之后它什么都不做.
我在1分钟后看到以下错误:
Unable to open browser with url: 'https://www.google.com' (Root cause: org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist
(Driver info: chromedriver=2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
Run Code Online (Sandbox Code Playgroud)
我的配置:
Chrome:66 ChromeBrowser:2.39.56
PS在Firefox中一切正常
selenium google-chrome webdriver selenium-chromedriver selenium-webdriver
在python-selenium chrome_options中,以下两个选项到底有什么区别,我知道两者都运行selenium脚本而不打开浏览器。
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
Run Code Online (Sandbox Code Playgroud) 我也有一个带有 UI 的 ubuntu 服务器。你可以通过触发 mvn test 命令来执行测试用例。但问题是当我从另一台机器通过终端对机器执行 ssh 时,我收到以下错误 -
unknown error: DevToolsActivePort file doesn't exist
(Driver info: chromedriver=2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7),platform=Linux 4.4.0-121-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.04 seconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'ubuntu-test', ip: 'X.X.X.X', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-121-generic', java.version: '1.8.0_171'
Driver info: driver.version: ChromeDriver
Run Code Online (Sandbox Code Playgroud)
但是,如果我通过 remmina 远程控制机器,然后执行该机器终端的相同命令,则相同的命令会成功启动 chrome。
linux selenium google-chrome selenium-chromedriver selenium-webdriver
线程函数中的Java代码:
System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--user-data-dir="+config.chromeUserDir);
chromeOptions.addArguments("--profile-directory="+profile);
chromeOptions.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://www.google.com");
Run Code Online (Sandbox Code Playgroud)
并使用以下代码创建对象并在线程中启动
Driver d1 = new Driver(profile);
d1.start();
Driver d2 = new Driver(profile1);
d1.start();
Run Code Online (Sandbox Code Playgroud)
已经创建了两个不同的配置文件,代码在单线程下运行良好,但在多线程下它不会在两个单独的窗口中打开谷歌网站。它说,
Starting ChromeDriver 2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac) on port 25692
Only local connections are allowed.
Starting ChromeDriver 2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac) on port 25954
Only local connections are allowed.
Oct 14, 2018 2:10:46 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Oct 14, 2018 2:10:46 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Created new …Run Code Online (Sandbox Code Playgroud)