最近,我将Mac OS更新为“ Mojave版本10.14”和“ safari版本12.0”,之后我无法使用safari浏览器。之前运行良好。 我是硒“ 3.0.0” 这是我的代码:
方案1:
case "safari":
DesiredCapabilities cap = DesiredCapabilities.safari();
driver = new SafariDriver(cap);
break;
错误:
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=safari, safari.options=org.openqa.selenium.safari.SafariOptions@10eff, version=, platform=MAC}], required capabilities = Capabilities [{}]
Build info: version: '3.0.0', revision: '350cf60', time: '2016-10-13 10:48:57 -0700'
System info: host: 'xxxx-MacBook-Pro.local', ip: 'xxxxx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14', java.version: '1.8.0_131'
Driver info: driver.version: SafariDriver
方案2:
SafariOptions options = new SafariOptions();
options.setUseTechnologyPreview(true);
WebDriver driver = new SafariDriver(options);
driver.get("http://www.google.com");
driver.quit();
错误:
Exception in thread "main" org.openqa.selenium.WebDriverException: SafariDriver requires Safari 10 running on OSX El Capitan or greater.
Build info: version: '3.0.0', revision: '350cf60', time: '2016-10-13 10:48:57 -0700'
System info: host: 'xxxx-MacBook-Pro.local', ip: 'xxxxx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14', java.version: '1.8.0_131'
Driver info: driver.version: SafariDriver
at org.openqa.selenium.safari.SafariDriver.getExecutor(SafariDriver.java:75)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:62)
在两种情况下,我都无法运行测试用例,请有人帮助我。谢谢。
答案 0 :(得分:1)
此错误消息...
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=safari, safari.options=org.openqa.selenium.safari.SafariOptions@10eff, version=, platform=MAC}], required capabilities = Capabilities [{}] Build info: version: '3.0.0', revision: '350cf60', time: '2016-10-13 10:48:57 -0700' System info: host: 'xxxx-MacBook-Pro.local', ip: 'xxxxx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14', java.version: '1.8.0_131'
...表示 SafariDriver 无法启动/产生新的 WebBrowser ,即 Safari浏览器会话。
您的主要问题是所使用的二进制版本之间的不兼容性:
因此 JDK v8u131 和 Selenium Client v3.0.0
之间存在明显的不匹配@Test
。