Search code examples
rubywatir

How to set the browser version in ruby selenium(WATIR)


Since the release of CFT (Chrome For Automation), it's possible to specify the browser version in Selenium. I've come across a Java solution that accomplishes this using ChromeOptions:

java

ChromeOptions options = new ChromeOptions();
options.setBrowserVersion("116");

This code automatically downloads and uses version 116. However, I'm uncertain about how to achieve the same in Ruby Selenium and WATIR. Could you please guide me on how to do this?


Solution

  • As I see in the docs, there is :browser_version option

    require "watir"
    
    browser_options = {
      browser_name: "Chrome",
      browser_version: "116",
    }
    
    browser = Watir::Browser.new(:chrome, options: browser_options)