Created
September 29, 2021 20:48
-
-
Save gmmoreira/f586529e5e1902b763906c8151e8519c to your computer and use it in GitHub Desktop.
Revisions
-
gmmoreira created this gist
Sep 29, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ # I had to automate a few tasks in my browser with my current logged session, but by default # Selenium always starts a new session. # After some research, the only way I found to attach Selenium to my running browser session # was through the debugger address option. # Start chrome with the command line option: google-chrome --remote-debugging-port=8181 # Then start selenium webdriver with the debug address option (I could only find the option # in latest selenium-webdriver gem (v4.0)) require 'bundler/inline' gemfile do source 'https://rubygems.org' gem 'watir' gem 'rexml' # So far, only selenium-webdriver 4.0 has support for debugger_address option gem 'selenium-webdriver', '~> 4.0.0.rc1' end require 'watir' require 'rexml' options = Selenium::WebDriver::Chrome::Options.new(debugger_address: '127.0.0.1:8181') driver = Selenium::WebDriver.for(:chrome, options: options) browser = Watir::Browser.new(driver) # do whatever you need: browser.goto('https://foo.bar'); browser.div(id: 'id123')