我在Windows 10上使用Opera-chromium-driver 2.45在Opera 60上运行自动化测试时遇到问题。我使用了selenium-standalone-server-3.4.0。在MacOs Mojave上,这种驱动程序和硒的组合很好用,但是在Windows 10 Opera上开始运行,但是引发了奇怪的错误(未知错误:DevToolsActivePort文件不存在)。
我试图像在stackoverflow上的其他帖子中一样添加/删除OperaOptions,例如“ --headless”,“-no-sandbox”等,但是这些都无济于事。与Opera 56和Opera-chromium-driver 2.40相同的代码在Windows上可以运行,但是新的驱动程序会抛出此奇怪的异常。
这是我的代码示例
DesiredCapabilities dc = new DesiredCapabilities();
//Opera60
OperaOptions oo = new OperaOptions();
oo.addArguments("--headless");
oo.addArguments("--disable-gpu");
oo.addArguments("--no-first-run");
//I have generate link in system to get always "latest" opera
oo.setBinary("C:\\Program Files\\Opera\\latest\\opera.exe");
System.setProperty("webdriver.opera.driver", "C:\\Users\\root.DESKTOP-KFASMSK\\controller_code\\controller_dependencies\\stuff\\drivers\\WINDOWS\\operadriver.exe");
dc.setCapability(OperaOptions.CAPABILITY, oo);
dc.setBrowserName("operablink");
this.driver = new RemoteWebDriver(new URL(operation.getSeleniumAddress()), dc);
这是硒异常的一部分
Caused by: org.openqa.selenium.WebDriverException: unknown error: Opera failed to start: crashed
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:/Program Files/Opera/latest/opera.exe is no longer running, so OperaDriver is assuming that Opera has crashed.)
(Driver info: OperaDriver=2.45.3255 (O60),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 868 milliseconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'DESKTOP-KFASMSK', ip: '10.0.0.7', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_161'
Driver info: driver.version: OperaDriver
答案 0 :(得分:0)
尝试再添加一个参数oo.addArguments("--allow-elevated-browser");
。