2

我正在尝试在 Mac OS X 10.5 上使用 watir-webdriver 驱动 Opera

顺便提一下,我在 Mac OS X 10.6 上驱动它没有问题。此外,我能够在 Mac OS X 10.5 上驱动 Internet Explorer、Firefox 和 Chrome。

它是完全修补的机器,Mac OS X 10.5.8,具有 4 GB RAM。

$ ruby -v
ruby 1.8.6 (2009-06-08 patchlevel 369) [universal-darwin9.0]

$ gem -v
1.4.2

$ java -version
java version "1.5.0_30"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_30-b03-389-9M3425)
Java HotSpot(TM) Client VM (build 1.5.0_30-161, mixed mode)

Xcode 3.1.4、Opera 11.51、selenium-webdriver 2.6.0、selenium-server-standalone-2.6.0.jar、watir-webdriver 0.3.3。

这就是我得到的:

$ irb

>> require "watir-webdriver"
=> true

>> b = Watir::Browser.new :opera
Selenium::WebDriver::Error::UnhandledError: Could not find a runtime for script injection
Build info: version: '2.6.0', revision: '13840', time: '2011-09-13 14:55:30'
System info: os.name: 'Mac OS X', os.arch: 'i386', os.version: '10.5.8', java.version: '1.5.0_30'
Driver info: driver.version: OperaDriver (org.openqa.selenium.WebDriverException)
    from [remote server] com.opera.core.systems.scope.services.ums.EcmaScriptDebugger(EcmaScriptDebugger.java):164:in `init'
    from [remote server] com.opera.core.systems.ScopeServices(ScopeServices.java):274:in `initializeServices'
    from [remote server] com.opera.core.systems.ScopeServices(ScopeServices.java):250:in `init'
    from [remote server] com.opera.core.systems.OperaDriver(OperaDriver.java):360:in `init'
    from [remote server] com.opera.core.systems.OperaDriver(OperaDriver.java):339:in `start'
    from [remote server] com.opera.core.systems.OperaDriver(OperaDriver.java):293:in `<init>'
    from [remote server] sun.reflect.NativeConstructorAccessorImpl(NativeConstructorAccessorImpl.java):-2:in `newInstance0'
    from [remote server] sun.reflect.NativeConstructorAccessorImpl(NativeConstructorAccessorImpl.java):39:in `newInstance'
    from [remote server] sun.reflect.DelegatingConstructorAccessorImpl(DelegatingConstructorAccessorImpl.java):27:in `newInstance'
    from [remote server] java.lang.reflect.Constructor(Constructor.java):501:in `newInstance'
    from [remote server] org.openqa.selenium.remote.server.DefaultDriverFactory(DefaultDriverFactory.java):88:in `callConstructor'
    from [remote server] org.openqa.selenium.remote.server.DefaultDriverFactory(DefaultDriverFactory.java):82:in `newInstance'
    from [remote server] org.openqa.selenium.remote.server.DefaultSession$BrowserCreator(DefaultSession.java):156:in `call'
    from [remote server] org.openqa.selenium.remote.server.DefaultSession$BrowserCreator(DefaultSession.java):1:in `call'
    from [remote server] java.util.concurrent.FutureTask$Sync(FutureTask.java):269:in `innerRun'
    from [remote server] java.util.concurrent.FutureTask(FutureTask.java):123:in `run'
... 3 levels...
    from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.6.0/lib/selenium/webdriver/remote/response.rb:45:in `assert_ok'
    from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.6.0/lib/selenium/webdriver/remote/response.rb:15:in `initialize'
    from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.6.0/lib/selenium/webdriver/remote/http/common.rb:54:in `new'
    from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.6.0/lib/selenium/webdriver/remote/http/common.rb:54:in `create_response'
    from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.6.0/lib/selenium/webdriver/remote/http/default.rb:64:in `request'
    from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.6.0/lib/selenium/webdriver/remote/http/common.rb:35:in `call'
    from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.6.0/lib/selenium/webdriver/remote/bridge.rb:410:in `raw_execute'
    from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.6.0/lib/selenium/webdriver/remote/bridge.rb:88:in `create_session'
    from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.6.0/lib/selenium/webdriver/remote/bridge.rb:68:in `initialize'
    from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.6.0/lib/selenium/webdriver/opera/bridge.rb:27:in `initialize'
    from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.6.0/lib/selenium/webdriver/common/driver.rb:41:in `new'
    from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.6.0/lib/selenium/webdriver/common/driver.rb:41:in `for'
    from /Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.6.0/lib/selenium/webdriver.rb:81:in `for'
    from /Library/Ruby/Gems/1.8/gems/watir-webdriver-0.3.3/lib/watir-webdriver/browser.rb:35:in `initialize'
    from (irb):2:in `new'
4

1 回答 1

2

“Could not find a runtime for script injection”表示当前激活的选项卡/文档不是脚本可注入的;OperaDriver 无法将 JavaScript 注入文档。

这适用于 Opera 中的某些类型的页面,例如“opera:about”和一些错误页面(想到不支持的协议)。

您可以手动打开 Opera(使用 -autotestmode 参数)并关闭所有打开的选项卡,然后再试一次吗?

(顺便说一下,这个问题不应该出现在 Opera 的下一个版本 Opera 12 中。)

有关更多上下文:http ://code.google.com/p/selenium/issues/detail?id=2470

于 2011-09-20T11:10:59.880 回答