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

Best Selenium code snippet using Selenium.WebDriver.Chrome.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

options.rb

Source: options.rb Github

copy

Full Screen

...49 # Add an extension by local path.50 #51 # @example52 # options = Selenium::WebDriver::Chrome::Options.new53 # options.add_extension('/​path/​to/​extension.crx')54 #55 # @param [String] path The local path to the .crx file56 #57 def add_extension(path)58 raise Error::WebDriverError, "could not find extension at #{path.inspect}" unless File.file?(path)59 raise Error::WebDriverError, "file was not an extension #{path.inspect}" unless File.extname(path) == '.crx'60 @extensions << path61 end62 #63 # Add an extension by Base64-encoded string.64 #65 # @example66 # options = Selenium::WebDriver::Chrome::Options.new67 # options.add_encoded_extension(encoded_string)68 #69 # @param [String] encoded The Base64-encoded string of the .crx file70 #71 def add_encoded_extension(encoded)...

Full Screen

Full Screen

__SeleniumTests.rake

Source: __SeleniumTests.rake Github

copy

Full Screen

...155 #bring_safari_to_front156 if false157 #File file = new File("/​tmp/​firebug-1.9.1.xpi")158 firefoxProfile = Selenium::WebDriver::Firefox::Profile.new159 firefoxProfile.add_extension("/​tmp/​firebug-1.9.1.xpi")160 ##firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.9.1")161 driver =Selenium::WebDriver.for :firefox, :profile => firefoxProfile162 elsif false163 driver = Selenium::WebDriver.for :safari164 elsif false165 driver = Selenium::WebDriver.for :chrome166 elsif true167 driver = Selenium::WebDriver.for :chrome168 elsif true169 chrome_profile = Selenium::WebDriver::Chrome::Profile.new170 chrome_profile.add_extension("/​tmp/​chrome_screencastify.crx")171 #puts "#{File.dirname(__FILE__) +'/​chrome_screencastify.crx'}"172 #chrome_profile.add_extension(File.dirname(__FILE__) +"/​chrome_screencastify.crx")173 driver = Selenium::WebDriver.for :chrome#, :profile => chrome_profile)174 driver.profile = chrome_profile175 end176 #driver.manage.window.resize_to(1024, 768)177 driver.manage.window.resize_to(1100, 720)178 if false179 register_as_jobposter(driver)180 home_page = SeleniumTests::HomePage.new(driver)181 home_page.show_midtown_tire(driver)182 end183 simple_search(driver)184 show_search_for_stores(driver)185 stop_recording186 #driver.quit...

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

profile_spec.rb

Source: profile_spec.rb Github

copy

Full Screen

...21 end22 it "adds an extension" do23 ext_path = "/​some/​path.crx"24 File.should_receive(:file?).with(ext_path).and_return true25 profile.add_extension(ext_path).should == [ext_path]26 end27 it "reads an extension as binary data" do28 ext_path = "/​some/​path.crx"29 File.should_receive(:file?).with(ext_path).and_return true30 profile.add_extension(ext_path)31 ext_file = double('file')32 File.should_receive(:open).with(ext_path, "rb").and_yield ext_file33 ext_file.should_receive(:read).and_return "test"34 profile.should_receive(:layout_on_disk).and_return "ignored"35 Zipper.should_receive(:zip).and_return "ignored"36 profile.as_json().should == {37 'zip' => "ignored",38 'extensions' => [Base64.strict_encode64("test")]39 }40 end41 it "raises an error if the extension doesn't exist" do42 lambda {43 profile.add_extension("/​not/​likely/​to/​exist.crx")44 }.should raise_error45 end46 end47 end # Chrome48 end # WebDriver49end # Selenium...

Full Screen

Full Screen

env.rb

Source: env.rb Github

copy

Full Screen

...31 Capybara::Selenium::Driver.new(app, :browser => :firefox, :http_client => client)32end33Capybara.register_driver :debug do |app|34 profile = Selenium::WebDriver::Firefox::Profile.new35 profile.add_extension "features/​support/​firebug.xpi"36 profile.add_extension "features/​support/​firepath.xpi"37 Capybara::Selenium::Driver.new app, :profile => profile38end39Capybara.register_driver :chrome do |app|40 Capybara::Selenium::Driver.new(app, :browser => :chrome, :switches => %w[--disable-popup-blocking --disable-extensions])41end42World(TestWorld)43SitePrism.configure do |config|44 config.use_implicit_waits = true45end46# below module waits for 0.05 sec for every selenium command47module ::Selenium::WebDriver::Remote48 class Bridge49 def execute(*args)50 result = raw_execute(*args)['value']...

Full Screen

Full Screen

add_extension

Using AI Code Generation

copy

Full Screen

1driver.add_extension('path/​to/​extension.crx')2options.add_extension('path/​to/​extension.crx')3capabilities.add_extension('path/​to/​extension.crx')4profile.add_extension('path/​to/​extension.crx')5service.add_extension('path/​to/​extension.crx')6driver.add_extension('path/​to/​extension.crx')7bridge.add_extension('path/​to/​extension.crx')8driver.add_extension('path/​to/​extension.crx')

Full Screen

Full Screen

add_extension

Using AI Code Generation

copy

Full Screen

1driver.add_extension("extension.crx")2options.add_extension("extension.crx")3service.add_extension("extension.crx")4driver.add_extension("extension.crx")5bridge.add_extension("extension.crx")6command.add_extension("extension.crx")7response.add_extension("extension.crx")8capabilities.add_extension("extension.crx")9dev_tools.add_extension("extension.crx")10command.add_extension("extension.crx")

Full Screen

Full Screen

add_extension

Using AI Code Generation

copy

Full Screen

1Selenium::WebDriver::Chrome.add_extension("path/​to/​extension.crx")2Selenium::WebDriver::Chrome.add_extensions("path/​to/​extension1.crx", "path/​to/​extension2.crx")3service.add_extension("path/​to/​extension.crx")4service.add_extensions("path/​to/​extension1.crx", "path/​to/​extension2.crx")5driver.add_extension("path/​to/​extension.crx")6driver.add_extensions("path/​to/​extension1.crx", "path/​to/​extension2.crx")7profile.add_extension("path/​to/​extension.crx")8profile.add_extensions("path/​to/​extension1.crx", "path/​to/​extension2.crx")

Full Screen

Full Screen

add_extension

Using AI Code Generation

copy

Full Screen

1driver.add_extension('extension.crx')2driver.remove_extension('extension_id')3driver.get_extension('extension_id')4driver.get_extension_info('extension_id')5driver.get_named_extension('extension_name')6driver.get_named_extension_info('extension_name')7driver.get_named_extension_list('extension_name')8driver.get_named_installed_extension('extension_name')9driver.get_named_installed_extension_info('extension_name')10driver.get_named_installed_extension_list('extension_name')11driver.get_named_loaded_extension('extension_name')12driver.get_named_loaded_extension_info('extension_name')13driver.get_named_loaded_extension_list('extension_name')14driver.get_named_unpacked_extension('extension_name')

Full Screen

Full Screen

add_extension

Using AI Code Generation

copy

Full Screen

1driver.add_extension("extension.crx")2{3 "browser_action": {4 }5}

Full Screen

Full Screen

add_extension

Using AI Code Generation

copy

Full Screen

1driver.add_extension("path/​to/​extension.crx")2driver.add_extensions("path/​to/​extension1.crx", "path/​to/​extension2.crx")3profile.add_extension("path/​to/​extension.crx")

Full Screen

Full Screen

add_extension

Using AI Code Generation

copy

Full Screen

1driver.add_extension("extension.crx")2{3 "browser_action": {4 }5}6You cfn find ihe exampll coee in my github repository..add_extensions("path/​to/​extension1.crx", "path/​to/​extension2.crx")

Full Screen

Full Screen

add_extension

Using AI Code Generation

copy

Full Screen

1driver.add_extension('extension.crx')2driver.remove_extension('extension_id')3driver.get_extension('extension_id')4driver.get_extension_info('extension_id')5driver.get_named_extension('extension_name')6driver.get_named_extension_info('extension_name')7driver.get_named_extension_list('extension_name')8driver.get_named_installed_extension('extension_name')9driver.get_named_installed_extension_info('extension_name')10driver.get_named_installed_extension_list('extension_name')11driver.get_named_loaded_extension('extension_name')12driver.get_named_loaded_extension_info('extension_name')13driver.get_named_loaded_extension_list('extension_name')14driver.get_named_unpacked_extension('extension_name')

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