Selenium:
browser = Selenium::WebDriver.for :chrome
Watir (with some options):
opts = Selenium::WebDriver::Chrome::Options.new
opts.add_option('useAutomationExtension', false)
opts.add_argument('--disable-infobars')
opts.add_argument('--disable-notifications')
browser = Watir::Browser.new :chrome, options: opts
Selenium:
opts = Selenium::WebDriver::Chrome::Options.new
opts.add_option('binary', $path_container)
browser = Selenium::WebDriver.for :chrome, options: opts
Watir:
opts = Selenium::WebDriver::Chrome::Options.new
opts.add_option('useAutomationExtension', false)
opts.add_argument('--disable-infobars')
opts.add_argument('--disable-notifications')
opts.add_option('binary', $path_container)
browser = Watir::Browser.new :chrome, options: opts
Combined into a function (where $use_container is the Boolean switch):
Selenium:
def open_browser()if $use_container
opts = Selenium::WebDriver::Chrome::Options.new
opts.add_option('binary', $path_container)
browser = Selenium::WebDriver.for :chrome, options: opts
else
browser = Selenium::WebDriver.for :chrome
end
return browser
end
Watir:
def open_browser()
opts = Selenium::WebDriver::Chrome::Options.new
opts.add_option('useAutomationExtension', false)
opts.add_argument('--disable-infobars')
opts.add_argument('--disable-notifications')
if $use_container
opts.add_option('binary', $path_container)
end
browser = Watir::Browser.new :chrome, options: opts
return browser
end
No comments:
Post a Comment