4

我正在尝试使用 Selenium RC 打开 safari。但是,Safari 实例已创建并保持在请求连接模式(SafariDriver 在 ws://localhost:3078/wd 请求连接)。

require "selenium-webdriver"
caps = Selenium::WebDriver::Remote::Capabilities.safari
browser = Selenium::WebDriver.for :remote, :url=>"http://localhost:4444/wd/hub",    :desired_capabilities=>caps

上面的东西挂断并失败 - Selenium::WebDriver::Error::UnknownError: Executor has not been started yet (java.lang.IllegalStateException) from [remote server] com.google.common.base.Preconditions(Preconditions.java ):145:in checkState' from [remote server] org.openqa.selenium.safari.SafariDriverCommandExecutor(SafariDriverCommandExecutor.java):123:inexecute' from [remote server] org.openqa.selenium.remote.RemoteWebDriver(RemoteWebDriver.java):432:in execute' from [remote server] org.openqa.selenium.remote.RemoteWebDriver(RemoteWebDriver.java):140:instartSession' from [remote server] org.openqa.selenium.remote.RemoteWebDriver(RemoteWebDriver.java ):95:in <init>' from [remote server] org.openqa.selenium.safari.SafariDriver(SafariDriver.java):33:in'来自 [远程服务器] sun.reflect.NativeConstructorAccessorImpl(NativeConstructorAccessorImpl.java):-2:in newInstance0' from [remote server] sun.reflect.NativeConstructorAccessorImpl(NativeConstructorAccessorImpl.java):39:innewInstance' 来自 [远程服务器] sun.reflect.DelegatingConstructorAccessorImpl(DelegatingConstructorAccessorImpl.java):27:in newInstance' from [remote server] java.lang.reflect.Constructor(Constructor.java):513:innewInstance' 来自[远程服务器] java.lang.Class(Class.java):355:innewInstance0' from [remote server] java.lang.Class(Class.java):308:innewInstance' 来自 [远程服务器] org.openqa.selenium.remote.server.DefaultDriverFactory(DefaultDriverFactory.java):61:in callConstructor' from [remote server] org.openqa.selenium.remote.server.DefaultDriverFactory(DefaultDriverFactory.java):52:innewInstance' 来自 [远程服务器] org.openqa.selenium.remote.server.DefaultSession$BrowserCreator(DefaultSession. java):197:in call' from [remote server] org.openqa.selenium.remote.server.DefaultSession$BrowserCreator(DefaultSession.java):1:incall' ... 4 个级别...来自 [远程服务器] java.util.concurrent.ThreadPoolExecutor$Worker(ThreadPoolExecutor.java):908:in run' from [remote server] java.lang.Thread(Thread.java):680:inrun' 来自 /Users/demo/.rvm/ gems/ruby-1.9.2-p180/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/response.rb:52:in assert_ok' from /Users/demo/.rvm/gems/ruby-1.9.2-p180/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/response.rb:15:ininitialize' 来自 /Users/demo/.rvm/gems/ruby- 1.9.2-p180/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/http/common.rb:59:innew' from /Users/demo/.rvm/gems/ruby-1.9.2-p180/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/http/common.rb:59:in来自/Users/demo/.rvm/gems/ruby-1.9.2-p180/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/http/default.rb:59:in request' from /Users/demo/.rvm/gems/ruby-1.9.2-p180/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/http/common.rb:40:incall 的 create_response'来自 /Users/demo/.rvm/gems/ruby-1.9.2-p180/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/bridge.rb:598:in raw_execute' from /Users/demo/.rvm/gems/ruby-1.9.2-p180/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/bridge.rb:92:increate_session' 来自 /Users/ demo/.rvm/gems/ruby-1.9.2-p180/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/bridge.rb:68:in initialize' from /Users/demo/.rvm/gems/ruby-1.9.2-p180/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/common/driver.rb:33:innew' 来自 /Users/demo/.rvm /gems/ruby-1.9.2-p180/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/common/driver.rb:33:in for' from /Users/demo/.rvm/gems/ruby-1.9.2-p180/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver.rb:65:infor' from (irb):7

4

1 回答 1

0

在使用 Ruby 中的 Selenium Webdriver 时,我一直遇到这个问题。我解决了几次,但错误又回来了。所以我编写了我的 rspec 测试,以供 Windows 上的 jRuby 加载,并在 Java 中运行 Selenium 调用。Safari 现在可以工作了。

于 2013-09-08T04:39:37.490 回答