简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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