简体   繁体   English

使用watir的goto功能时出现未知错误

[英]I get unknown error when using the goto function of watir

I am running this code: 我正在运行此代码:

require 'watir'
browser = Watir::Browser.new(:chrome)
browser.goto('example.com')
puts browser.html

and I get this error: 我得到这个错误:

~/.rvm/gems/ruby-2.3.0/gems/selenium-webdriver-3.0.3/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok': unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"27739.1","isDefault":true},"id":1,"name":"","origin":"://"} (Selenium::WebDriver::Error::UnknownError)

the error is generated by the browser.goto('example.com') instruction, because if I run 该错误是由browser.goto('example.com')指令生成的,因为如果我运行

require 'watir'
browser = Watir::Browser.new(:chrome)
sleep 10

it shows me the browser windows for 10 seconds but it is useless if I can go to any page, any ideas about what is going wrong? 它向我显示了浏览器窗口10秒钟,但是如果我可以转到任何页面,关于出问题的任何想法,这是没有用的?

To avoid closing browser, you need to include this code now 为避免关闭浏览器,您需要立即包含此代码

require 'watir'
caps = Selenium::WebDriver::Remote::Capabilities.chrome(chrome_options: {detach: true})
b = Watir::Browser.new :chrome, desired_capabilities: caps
b.goto('www.example.com')

Try this, it works fine. 试试这个,它工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM