Search code examples
rubywatir

Chrome detach option is no longer working


There is a question for Ruby Selenium Binding here

Selenium WebDriver in Ruby: Preventing the test from closing the browser window at end

He was trying to not to close the window of Chrome after the execution but it's not working. I have had the solution for this problem, the given below program works fine earlier, but now it's not working

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

When I execute this program, this program is giving the warning of

2019-11-19 09:33:37 WARN Watir ["use_capabilities"] You can pass values directly into Watir::Browser opt without needing to use :desired_capabilities

But I don't know how to use this Watir::Browser opt. Any help is appreciated.


Solution

  • You can pass Chrome Options using the following format:

    browser = Watir::Browser.new(
      :chrome,
      'goog:chromeOptions' => {detach: true}
    )