How to use add_extension method of Selenium.WebDriver.Firefox Package

Best Selenium code snippet using Selenium.WebDriver.Firefox.add_extension

browser.rb

Source: browser.rb Github

copy

Full Screen

...111 profile.log_file = browser_log_file_path("firefox")112 profile['network.cookie.cookieBehavior'] = 2 if @disable_cookies113 if ExecutionEnvironment::Features.noscript?114 untrusted = %w(bazaarvoice.com)115 profile.add_extension("vendor/​firefox_extensions/​noscript.xpi")116 profile["noscript.ABE.migration"] = 1117 profile["noscript.global"] = true118 profile["noscript.gtemp"] = ""119 profile["noscript.temp"] = ""120 profile["noscript.untrusted"] = untrusted.map { |domain| [domain, "http:/​/​#{domain}", "https:/​/​#{domain}"] }.flatten.join(' ')121 profile["noscript.version"] = "2.6.8.19"122 profile["noscript.visibleUIChecked"] = true123 Log.instance.debug "Running with 'noscript' plugin. Untrusted domains: #{untrusted}"124 end125 if ExecutionEnvironment::Features.akamai?126 profile.add_extension('vendor/​firefox_extensions/​modify_headers-0.7.1.1-fx.xpi', 'modifyheaders')127 profile.add_extension('vendor/​firefox_extensions/​firebug-2.0.4-fx.xpi', 'firebug')128 profile.add_extension('vendor/​firefox_extensions/​netExport-0.9b6.xpi', 'netexport')129 profile['modifyheaders.config.active'] = true130 profile['modifyheaders.config.alwaysOn'] = true131 profile['modifyheaders.config.openNewTab'] = true132 profile['modifyheaders.start'] = true133 headers = 'akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-extracted-values, akamai-x-get-nonces, akamai-x-get-ssl-client-session-id, akamai-x-get-true-cache-key, akamai-x-serial-no, akamai-x-cache-remote-on'134 profile['modifyheaders.headers.count'] = 1135 profile['modifyheaders.headers.action0'] = 'Add'136 profile['modifyheaders.headers.name0'] = 'Pragma'137 profile['modifyheaders.headers.value0'] = headers138 profile['modifyheaders.headers.enabled0'] = true139 profile['extensions.firebug.currentVersion'] = '2.0.4'140 profile['extensions.firebug.addonBarOpened'] = true141 profile['extensions.firebug.console.enableSites'] = true142 profile['extensions.firebug.script.enableSites'] = true143 profile['extensions.firebug.net.enableSites'] = true144 profile['extensions.firebug.previousPlacement'] = 1145 profile['extensions.firebug.allPagesActivation'] = 'on'146 profile['extensions.firebug.onByDefault'] = true147 profile['extensions.firebug.defaultPanelName'] = 'net'148 profile['extensions.firebug.netexport.alwaysEnableAutoExport'] = true149 profile['extensions.firebug.netexport.autoExportToFile'] = true150 profile['extensions.firebug.netexport.Automation'] = true151 profile['extensions.firebug.netexport.showPreview'] = false152 profile['extensions.firebug.netexport.includeResponseBodies'] = false153 profile['extensions.firebug.netexport.secretToken'] = 'macys'154 if ExecutionEnvironment.host_os == :windows155 profile['extensions.firebug.netexport.defaultLogDir'] = ExecutionEnvironment.log_directory.gsub('/​','\\')156 else157 profile['extensions.firebug.netexport.defaultLogDir'] = ExecutionEnvironment.log_directory158 end159 end160 profile.proxy = start_proxy if ExecutionEnvironment.proxy_enabled?161 profile.add_extension('vendor/​firefox_extensions/​JSErrorCollector.xpi')162 if ExecutionEnvironment.digital_analytics_enabled?('plugin')163 profile.add_extension("vendor/​firefox_extensions/​coremetricstools@coremetrics.xpi")164 end165 Selenium::WebDriver.for :firefox, :profile => profile166 else167 caps = Selenium::WebDriver::Remote::Capabilities.firefox(common_capabilities)168 Selenium::WebDriver.for(:remote, :url => ExecutionEnvironment.selenium_grid_hub, :desired_capabilities => caps)169 end170 end171 def setup_chrome172 unless ExecutionEnvironment.selenium_grid_hub.nil?173 caps = Selenium::WebDriver::Remote::Capabilities.chrome(common_capabilities)174 return Selenium::WebDriver.for :remote, :url => ExecutionEnvironment.selenium_grid_hub, :desired_capabilities => caps175 end176 if ExecutionEnvironment::Features.akamai?177 extensions = "--load-extension=#{Dir.getwd}/​vendor/​chrome_extensions/​HTTP_Spy/​,#{Dir.getwd}/​vendor/​chrome_extensions/​Modify_Headers/​"...

Full Screen

Full Screen

profile.rb

Source: profile.rb Github

copy

Full Screen

...89 self[WEBDRIVER_PREFS[:log_file]] = file90 end91 def add_webdriver_extension92 unless @extensions.has_key?(:webdriver)93 add_extension(WEBDRIVER_EXTENSION_PATH, :webdriver)94 end95 end96 #97 # Add the extension (directory, .zip or .xpi) at the given path to the profile.98 #99 def add_extension(path, name = extension_name_for(path))100 @extensions[name] = Extension.new(path)101 end102 def native_events?103 @native_events == true104 end105 def load_no_focus_lib?106 @load_no_focus_lib == true107 end108 def secure_ssl?109 @secure_ssl == true110 end111 def assume_untrusted_certificate_issuer?112 @untrusted_issuer == true113 end...

Full Screen

Full Screen

env.rb

Source: env.rb Github

copy

Full Screen

...10 profile['browser.download.manager.closeWhenDone'] = true11 profile['browser.startup.homepage_override.mstone'] = 'ignore'12 profile['browser.helperApps.neverAsk.saveToDisk'] = "text/​plain;application/​csv;text/​csv;application/​vnd.ms-excel;application/​octet-stream;application/​x-msdos-program;application/​x-apple-diskimage;application/​x-debian-package;application/​x-redhat-package-manager;image/​png"13 profile.assume_untrusted_certificate_issuer = false14 profile.add_extension("#{FileHelper.default_test_data_path}/​hostadmin-1.4.9.2-fx.xpi")15 profile.add_extension("#{FileHelper.default_test_data_path}/​empty_cache_button-2.7-fx.xpi")16 #profile.native_events = true17 profile18end19Capybara.register_driver :firefox do |app|20 Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => firefox_profile)21end22Capybara.register_driver :firefox_profile do |app|23 profile_address = "#{FileHelper.default_test_data_path}/​#{CONFIGS['global']['profile_name']}"24 profile = Selenium::WebDriver::Firefox::Profile.new profile_address25 profile.add_extension("#{FileHelper.default_test_data_path}/​autoauth-2.1-fx+fn.xpi")26 Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)27end28Capybara.register_driver :firefox_debug do |app|29 profile = Selenium::WebDriver::Firefox::Profile.new30 profile.add_extension("#{FileHelper.default_test_data_path}/​firebug-2.0.9-fx.xpi")31 profile['browser.startup.homepage_override.mstone'] = 'ignore'32 profile["extensions.firebug.console.enableSites"] = true33 profile["extensions.firebug.net.enableSites"] = true34 profile["extensions.firebug.script.enableSites"] = true35 profile["extensions.firebug.cookies.enableSites"] = true36 profile["extensions.firebug.allPagesActivation"] = "on"37 profile["extensions.firebug.currentVersion"] = "2.0.9"38 Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)39end40def chrome_prefs41 prefs = {42 :download => {43 :prompt_for_download => false,44 :default_directory => FileHelper.ff_download_path...

Full Screen

Full Screen

driver_config.rb

Source: driver_config.rb Github

copy

Full Screen

...9 #puts "Launching driver for firefox.........................."10 ENV['IS_UPA'] = "false" if ENV['IS_UPA'].nil?11 if ENV['IS_UPA']=="true"12 profile = Selenium::WebDriver::Firefox::Profile.new13 profile.add_extension("./​data/​har/​firebug-2.0.13.xpi")14 profile.add_extension("./​data/​har/​netExport-0.8.xpi")15 profile['extensions.firebug.allPagesActivation'] = "on"16 profile['extensions.firebug.defaultPanelName'] = "net"17 profile['extensions.firebug.net.enableSites'] = "true"18 profile['extensions.firebug.showFirstRunPage'] = "false"19 profile['extensions.firebug.netexport.alwaysEnableAutoExport'] = "true"20 profile['extensions.firebug.netexport.showPreview'] = "false"21 profile['extensions.firebug.netexport.defaultLogDir'] = File.absolute_path("./​reports/​upa")22 profile['extensions.firebug.netexport.defaultFileName'] = "upaReport.har"23 profile['extensions.firebug.netexport.jsonpCallback'] = "jsonCallback";24 @driver = Selenium::WebDriver.for :firefox, :profile => profile25 else26 @driver = Selenium::WebDriver.for :firefox27 end28 @driver.manage.timeouts.implicit_wait = 30...

Full Screen

Full Screen

taza_brower.rb

Source: taza_brower.rb Github

copy

Full Screen

...46 #driver.manage.timeouts.page_load = 12047 browser = Watir::Browser.new driver48 elsif ENV['BROWSER'] == 'firefox'49 profile = add_firefox_download_directory(params[:profile])50 profile.add_extension File.expand_path("../​../​../​../​google/​tools/​extensions/​firebug-1.11.2.xpi", __FILE__)51 profile.add_extension File.expand_path("../​../​../​../​google/​tools/​extensions/​JSErrorCollector.xpi", __FILE__)52 profile['extensions.firebug.currentVersion'] = "1.9.2"53 browser = Watir::Browser.new params[:browser], :profile => profile54 else55 browser = Watir::Browser.new params[:browser]56 end57 browser58 end59 def self.add_chrome_download_directory(profile)60 custom_profile = profile.nil? ? Selenium::WebDriver::Chrome::Profile.new : profile61 custom_profile["download.default_directory"] = custom_profile["download.default_directory"] rescue File.expand_path("../​onyx-automation/​temp")62 custom_profile["download.prompt_for_download"] = false63 custom_profile64 end65 def self.add_firefox_download_directory(profile)...

Full Screen

Full Screen

ff_lzy.rb

Source: ff_lzy.rb Github

copy

Full Screen

...7# https:/​/​github.com/​SeleniumHQ/​selenium/​wiki/​Ruby-Bindings8#profile = Selenium::WebDriver::Firefox::Profile.new9#capabilities = Selenium::WebDriver::Remote::Capabilities.firefox10#capabilities['firefox.page.customHeaders.Accept-Language'] = 'zh-CN,zh;q=0.9'11#profile.add_extension('./​headereditor.xpi')12##profile['browser.download.dir'] = 'C:\Users\Administrator\Downloads'13#profile['browser.download.dir'] = './​'14#profile['browser.download.folderList'] = 215##profile['browser.helperApps.neverAsk.saveToDisk'] = 'application/​pdf'16#profile['browser.helperApps.neverAsk.saveToDisk'] = 'application/​zip'17#browser = Watir::Browser.new :firefox, profile: profile, desired_capabilities: capabilities18#browser = Watir::Browser.new :firefox, profile: 'default-release' 19#options = Selenium::WebDriver::Firefox::Options.new(args: ['-headless', "-profile", "/​home/​lsq/​.mozilla/​firefox/​3hxb38kg.lsq"])20# options = Selenium::WebDriver::Firefox::Options.new(args: ["-profile", "/​home/​lsq/​.mozilla/​firefox/​3hxb38kg.lsq"])21# browser = Watir::Browser.new :firefox, options: options22################# test in windows can load extension ############23################ use firefox -p ###################24# browser = Watir::Browser.new :firefox, profile: 'lsq'25# browser = Watir::Browser.new :firefox, options: options ...

Full Screen

Full Screen

firefox.rb

Source: firefox.rb Github

copy

Full Screen

...9 puts "=>=>=> Your HAR (UPA) files will be created here : #{ENV['HAR_DIR']}"10 firebug = File.absolute_path(File.dirname(__FILE__)+"/​../​../​data/​firebug-2.0.13.xpi")11 net_export = File.absolute_path(File.dirname(__FILE__)+"/​../​../​data/​netExport-0.8.xpi")12 profile = Selenium::WebDriver::Firefox::Profile.new13 profile.add_extension(firebug)14 profile.add_extension(net_export)15 profile['extensions.firebug.currentVersion'] = "2.0.13"16 profile['extensions.firebug.allPagesActivation'] = "on"17 profile['extensions.firebug.defaultPanelName'] = "net"18 profile['extensions.firebug.net.enableSites'] = "true"19 profile['extensions.firebug.netexport.alwaysEnableAutoExport'] = "true"20 profile['extensions.firebug.netexport.showPreview'] = "false"21 profile['extensions.firebug.netexport.defaultLogDir'] = ENV['HAR_DIR'].to_s22 profile['extensions.firebug.netexport.defaultFileName'] = "upaReport.har"23 profile['extensions.firebug.netexport.jsonpCallback'] = "jsonCallback"24 driver = Selenium::WebDriver.for(:firefox, :profile => profile, :desired_cpabilities => caps)25 else26 driver = Selenium::WebDriver.for(:firefox, :desired_cpabilities => caps)27 end28 driver.manage.timeouts.implicit_wait = 30...

Full Screen

Full Screen

browser_profiles.rb

Source: browser_profiles.rb Github

copy

Full Screen

...3 def self.firefox_profile(uses_native_events=false)4 profile = Selenium::WebDriver::Firefox::Profile.new5 profile.secure_ssl=CONFIG.secure_ssl6 profile.assume_untrusted_certificate_issuer=CONFIG.untrust_ssl_cert7 profile.add_extension(File.dirname(__FILE__) + '/​extensions/​firebug-1.10.2.xpi')8 profile['extensions.firebug.currentVersion'] = '1.10.2' #Load without start page9 profile.native_events = uses_native_events10 profile11 end12 def self.firefox_with_proxy_profile(uses_native_events=false)13 profile = Selenium::WebDriver::Firefox::Profile.new14 profile.secure_ssl=CONFIG.secure_ssl15 profile.assume_untrusted_certificate_issuer=CONFIG.untrust_ssl_cert16 profile.add_extension(File.dirname(__FILE__) + '/​extensions/​firebug-1.10.2.xpi')17 profile['extensions.firebug.currentVersion'] = '1.10.2' #Load without start page18 profile.native_events = uses_native_events19 profile20 end21 def self.chrome_profile22 profile = Selenium::WebDriver::Chrome::Profile.new23 profile['download.prompt_for_download'] = false24 profile['download.default_directory'] = File.join("#{ENV['DOWNLOADS_DIR']}" || "#{REPO_ROOT}", 'tmp_downloads')25 profile26 end27 def self.chrome_with_ad_block_profile28 profile = Selenium::WebDriver::Chrome::Profile.new29 profile['download.prompt_for_download'] = false30 profile['download.default_directory'] = File.join("#{ENV["DOWNLOADS_DIR"]}" || "#{REPO_ROOT}", 'tmp_downloads')31 profile.add_extension(File.dirname(__FILE__) + '/​extensions/​AdBlock_v2.5.61.crx')32 profile33 end34 end#BrowserProfiles35end#AutomationFramework...

Full Screen

Full Screen

add_extension

Using AI Code Generation

copy

Full Screen

1profile.add_extension('/​path/​to/​extension.xpi')2profile.add_extension('/​path/​to/​extension.xpi')3profile.add_extension('/​path/​to/​extension.xpi')4profile.add_extension('/​path/​to/​extension.xpi')

Full Screen

Full Screen

add_extension

Using AI Code Generation

copy

Full Screen

1driver.add_extension('C:\Users\Kamal\Downloads\firebug-1.12.8-fx.xpi')2driver.add_extension('C:\Users\Kamal\Downloads\firebug-1.12.8-fx.xpi')3driver.add_extension('C:\Users\Kamal\Downloads\firebug-1.12.8-fx.xpi')4driver.add_extension('C:\Users\Kamal\Downloads\firebug-1.12.8-fx.xpi')5caps.add_extension('C:\Users\Kamal\Downloads\firebug-1.12.8-fx.xpi')6caps.add_extension('C:\Users\Kamal\Downloads\firebug-1.12.8-fx.xpi')

Full Screen

Full Screen

add_extension

Using AI Code Generation

copy

Full Screen

1profile.add_extension("c:/​path/​to/​extension.xpi")2profile.add_extension("c:/​path/​to/​extension.xpi")3profile.add_extension("c:/​path/​to/​extension.xpi")4profile.add_extension("c:/​path/​to/​extension.xpi")5profile.add_extension("c:/​path/​to/​extension.xpi")

Full Screen

Full Screen

StackOverFlow community discussions

Questions
Discussion

Unsupported command-line flag: --ignore-certificate-errors (in Ruby)

Enter password in dialog/prompt

How to setup Capybara with Safari Technology Preview in Ruby

Can you close all open windows in capybara?

remove alert confirms javascript with watir webdriver

Wrap each command in a rescue statement

Why am I not able to login to Quora using an automation package like Selenium or Watir?

Iterate through all form fields with selenium in ruby

ruby selenium xpath td css

Capybara headless download

The Ruby selenium-webdriver API doesn't expose a separate Chrome options object like Java/Python but you can set the options via "Capabilities".

The Capabilities web page provides a Ruby example and the table of recognized capabilities that you can inject. Plugging those together with excludeSwitches:

caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"excludeSwitches" => [ "--ignore-certificate-errors" ]})
driver = Selenium::WebDriver.for :chrome, desired_capabilities: caps

Take a look at Watir too, it's a front end for WebDriver.
Their examples show how you can send a :switches array which is passed straight through to the web driver so you can do the same. That makes adding other switches a bit easier rather than going through capabilities.

There is a chromedriver issue on the topic as well. There are posts detailing that you can add a --test-type argument to work around the certificate issue and ruby code examples like above.

https://stackoverflow.com/questions/24874707/unsupported-command-line-flag-ignore-certificate-errors-in-ruby

Blogs

Check out the latest blogs from LambdaTest on this topic:

How to get started with Load Testing?

We have all been in situations while using a software or a web application, everything is running too slow. You click a button and nothing is happening except a loader animation spinning for an infinite time.

Selenium with Python Tutorial: Running First PyUnit Script

This article is a part of our Content Hub. For more in-depth resources, check out our content hub on Selenium Python Tutorial.

Progressive Web Application: Statistics- Infographic

We love PWAs and seems like so do you ???? That’s why you are here. In our previous blogs, Testing a Progressive web app with LambdaTest and Planning to move your app to a PWA: All you need to know, we have already gone through a lot on PWAs so we decided to cut is short and make it easier for you to memorize by making an Infographic, all in one place. Hope you like it.

Why Vertical Text Orientation Is A Nightmare For Cross Browser Compatibility?

The necessity for vertical text-orientation might not seem evident at first and its use rather limited solely as a design aspect for web pages. However, many Asian languages like Mandarin or Japanese scripts can be written vertically, flowing from right to left or in case of Mongolian left to right. In such languages, even though the block-flow direction is sideways either left to right or right to left, letters or characters in a line flow vertically from top to bottom. Another common use of vertical text-orientation can be in table headers. This is where text-orientation property becomes indispensable.

Top 15 Best Books for JavaScript Beginners

This article is a part of our Content Hub. For more in-depth resources, check out our content hub on Selenium JavaScript Tutorial.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful