Last active
September 8, 2021 18:15
-
-
Save Snarp/67f3c8f846f0f4c1cd4641937040595e to your computer and use it in GitHub Desktop.
Initializes an instance of Watir::Browser using a specified Firefox profile.
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 characters
require 'watir' | |
require 'webdrivers/geckodriver' | |
# Source: | |
# <https://github.com/SeleniumHQ/selenium/issues/7796#issuecomment-555833317> | |
# Find your Firefox profile's directory by opening 'about:support' in the | |
# browser and scrolling down to the 'Profile Directory' field. | |
# | |
# Alternately, to create a new profile, go to 'about:profiles' and click | |
# "Create a new profile". When it is created, copy the "Root Directory" path. | |
@firefox_profile_dir = 'PROFILE PATH GOES HERE' | |
def init_browser | |
profile = @firefox_profile_dir | |
service = Selenium::WebDriver::Service.firefox(args: {marionette_port: 2828}) | |
options = Selenium::WebDriver::Firefox::Options.new(args: ["-profile", profile]) | |
driver = Selenium::WebDriver.for(:firefox, service: service, options: options) | |
@browser = Watir::Browser.new(driver) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment