我在Linux中构建了一个简单的脚本,但现在我正试图让它在Windows上运行。
代码是:
require 'watir-webdriver'
puts "Press enter when ready to continue"
gets
browser = Watir::Browser.start "http://www.google.com"
# do stuff
它在Ubuntu上完全按预期工作。但是当我在Windows上尝试它时,Firefox进程启动,但在你看到Firefox窗口之前就死掉了。这是在这个Windows安装上全新安装的Ruby,我以前从未在这台机器上使用它。
可能是什么问题?
编辑:命令行跟踪,按要求。
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver/firefox/launcher.rb:90:in `connect_until_stable': unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver/firefox/launcher.rb:55:in `block in launch'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver/common/socket_lock.rb:43:in `locked'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver/firefox/launcher.rb:51:in `launch'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver/firefox/bridge.rb:43:in `initialize'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver/common/driver.rb:53:in `new'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver/common/driver.rb:53:in `for'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver.rb:84:in `for'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/watir-webdriver-0.9.1/lib/watir-webdriver/browser.rb:46:in `initialize'
from bot.rb:8:in `new'
from bot.rb:8:in `<main>'
答案 0 :(得分:2)
Firefox中的this bug。您的选择是:
要试用木偶,请下载geckodriver并执行:
browser = Watir::Browser.new :firefox, marionette: true