使用Safari 10 / Selenium 3.0.1删除cookie时出现异常

时间:2017-01-05 17:56:34

标签: java macos selenium safari safaridriver

我在使用Safari 10.0中的原生SafariDriver添加和删除Cookie时出现问题:抛出通用WebDriverException,我正在寻找修复或解决方法。

以下组件发生这种情况:

  • Mac OS X 10.11.6(El Capitan)
  • Safari 10.0 [提供本地 SafariDriver实现]
  • Selenium 3.0.1

以下document表示Safari 10中的原生SafariDriver不再需要安装Selenium SafariDriver 扩展,而是依赖于Selenium 3.0或更高版本。并且我确保使用Selenium 3.x并且Selenium 2.x不在我的系统中。

在测试时,浏览器窗口具有橙色SmartSearch字段,并在单击测试窗口时抛出以下异常。我知道测试框架正在使用正确的音频驱动程序,因为以下系统属性,以及抛出的异常表明Selenium版本为3.0.1

webdriver.safari.driver Mac OS X 系统属性设置为/usr/bin/safaridriver

以下适用于Safari:

            driver.manage().getCookies();

以下操作系统无法使用Safari,但适用于Chrome

            driver.manage().addCookie(cookie);
            driver.manage().deleteAllCookies();

addCookie()

的异常堆栈跟踪
  

DEBUG [main](DefaultNavigator.java:201) - 捕获异常:   org.openqa.selenium.WebDriverException:未知的服务器端错误   处理命令时发生。 (警告:服务器没有   提供任何堆栈跟踪信息)命令持续时间或超时:4   毫秒

     

构建信息:版本:' 3.0.1',修订版:' 1969d75',

     

时间:' 2016-10-18 09:49:13 -0700'系统信息:主持人:' L-C02S61GDxxxx',ip:   ' 192.168.47.xxx,os.name:' Mac OS X',os.arch:' x86_64',os.version:   ' 10.11.6',java.version:' 1.8.0_112

     

驱动程序信息:   org.openqa.selenium.safari.SafariDriver功能   [{applicationCacheEnabled = true,rotate = false,databaseEnabled = true,   handlesAlerts = true,version = 11602.3.12.0.1,cleanSession = true,   platform = MAC,nativeEvents = true,locationContextEnabled = false,   webStorageEnabled = true,browserName = safari,javascriptEnabled = true,   cssSelectorsEnabled = true}]会话ID:   7513DEE7-DB0F-4CBD-B21E-D760C69880DB

     

DEBUG [main](AbstractTest.java:91) - ######执行测试:testSignInSuccess                   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)                   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)                   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)                   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)                   在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)                   在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)                   在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)                   在org.openqa.selenium.remote.RemoteWebDriver $ RemoteWebDriverOptions.addCookie(RemoteWebDriver.java:718)                   ...                   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)                   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)                   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)                   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)                   在org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)                   在org.junit.runners.BlockJUnit4ClassRunner $ 1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)                   在org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)                   在org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)                   在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)                   在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)                   在org.junit.runners.ParentRunner $ 3.run(ParentRunner.java:290)                   在org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:71)                   在org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)                   在org.junit.runners.ParentRunner.access $ 000(ParentRunner.java:58)                   在org.junit.runners.ParentRunner $ 2.evaluate(ParentRunner.java:268)                   在org.junit.runners.ParentRunner.run(ParentRunner.java:363)                   在org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)                   在org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)                   在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)                   在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)                   在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)                   在org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

1 个答案:

答案 0 :(得分:0)

这是safaridriver中的一个已知问题。它已在Safari 11中修复。