无法启动Chrome驱动程序-macOS-硒Java-测试

时间:2020-04-03 08:33:42

标签: java macos selenium-webdriver electron selenium-chromedriver

当我尝试进行maven安装时,此错误使进程停止 任何帮助都将如此巨大。自2天以来一直停滞。

失败的Java代码

ChromeOptions opt = new ChromeOptions();
opt.setBinary(System.getProperty("binary_path"));
ChromeDriverService service = new ChromeDriverService.Builder().build();
driver = new ChromeDriver(service, opt); <-- at this line.

控制台错误

[INFO] Running TestSuite
[TestNGContentHandler] [WARN] It is strongly recommended to add "<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >" at the top of your file, otherwise TestNG may fail or not work as expected.
Starting ChromeDriver 80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185}) on port 28707
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1585902743.548][WARNING]: FromSockAddr failed on netmask
[ERROR] Tests run: 11, Failures: 1, Errors: 0, Skipped: 10, Time elapsed: 1.386 s <<< FAILURE! - in TestSuite
[ERROR] setUpScript(com.***.TestBase)  Time elapsed: 1.149 s  <<< FAILURE!
org.openqa.selenium.WebDriverException: 
unknown error: DevToolsActivePort file doesn't exist
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' 

PS:它是一种电子应用程序,可在macOS中运行

1 个答案:

答案 0 :(得分:0)

您需要添加以下参数:

opt.addArguments("--disable-dev-shm-usage")

这是因为此消息 DevToolsActivePort文件不存在