selenium - 更改狩猎地点。

标签 selenium safari selenium-webdriver

我是 Safari 新手,当我给予时:

new SafariDriver()

我明白了:

java.lang.IllegalStateException: The expected Safari data directory does not exist: /Users/root/Library/Safari
    at com.google.common.base.Preconditions.checkState(Preconditions.java:177)
    at org.openqa.selenium.safari.SafariExtensions.getInstallDirectory(SafariExtensions.java:179)
    at org.openqa.selenium.safari.SafariExtensions.install(SafariExtensions.java:213)
    at org.openqa.selenium.safari.SafariDriverCommandExecutor.start(SafariDriverCommandExecutor.java:95)
    at org.openqa.selenium.safari.SafariDriver.startClient(SafariDriver.java:73)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:112)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:127)
    at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:59)
    at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:52)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
    at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
    at com.apple.ist.ets.monsoon.test.ProfilePage.workAround(ProfilePage.groovy:79)
    at com.apple.ist.ets.monsoon.test.ProfilePage.initWebContext(ProfilePage.groovy:88)
    at com.apple.ist.ets.test.BaseWebTest.setUp(BaseWebTest.java:67)
    at com.apple.ist.ets.test.BaseJUnitTestCase.preMethod(BaseJUnitTestCase.java:936)
    at com.apple.ist.ets.test.TestCase.preProcess(TestCase.java:495)
    at com.apple.ist.ets.test.ExecutionComponent.run(ExecutionComponent.java:1481)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)

我什至尝试了以下方法:

        DesiredCapabilities cap = new DesiredCapabilities();
        cap.setCapability("safari.dataDir","/Users/me/Library/Safari")
        driver = new SafariDriver(cap);

但面临同样的问题。我哪里出错了?

谢谢。

最佳答案

这似乎是一个已知问题。

https://code.google.com/p/selenium/issues/detail?id=5293

您正在搜索的文件夹是否存在?

关于selenium - 更改狩猎地点。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23365931/

相关文章:

python - 使用selenium获取不同的属性值

php - 解析 php 网络驱动程序中的错误

python - 自动化浏览器操作 - 单击提交按钮错误 - "Click succeeded but Load Failed. .."

javascript - 两个元素在 selenium 中引用相同的 Xpath

javascript - 简单的 JS 适用于除 Safari 之外的所有浏览器

css - WebKit CSS 内容 Unicode 错误?

javascript - 如何检查 JavaScript 文件是否尚未加载或正在加载

java - 如何从命令提示符运行已完成的 Selenium-RC 项目?

iphone - iOS上的文件关联-从Safari打开纯文本文件

selenium - WebDriver 通过 xPath 查找元素,如果未找到元素,则不会超时,屏幕只是卡在那里。