How do I disable add-ons in firefox when using sel

2019-02-21 15:58发布

问题:

I'm using Capybara selenium in my Rails project (on an Ubuntu 10.04 system) and I've just upgraded firefox now when I'm running my tests firefox loads but it now has all the add-ons installed and it waits until I set each one up for the first time.

Is there a way to disable all these add-ons when starting selenium?

OR

Is there a way to setup all my add-ons and save the settings so that it doesn't prompt me everytime the tests are ran?

Update

If I change it over to use chrome it works fine with that.

 Capybara.register_driver :selenium do |app|
   Capybara::Selenium::Driver.new(app, :browser => :chrome)
 end

 Capybara.javascript_driver = :selenium

I would like to do the tests with firefox though. I've setup a 'test' profile under firefox and tried using it with the following:

Capybara.register_driver :selenium_firefox_custom do |app|
  Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => "test")
end

Capybara.default_driver = :selenium_firefox_custom

Which didn't work, it still tried to load my default profile.

I'm using the git version of capybara;

capybara (1.1.2)
  mime-types (>= 1.16)
  nokogiri (>= 1.3.3)
  rack (>= 1.0.0)
  rack-test (>= 0.5.4)
  selenium-webdriver (~> 2.0)
  xpath (~> 0.1.4)

I've also tried using Capybara.javascript_driver = :selenium_firefox_custom

回答1:

Try using a custom profile, and naming it however you like:

Capybara.register_driver :selenium_firefox_custom do |app|
  Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => "custom")
end

Capybara.default_driver = :selenium_firefox_custom

Depending on the version you're using the API may have changed, but pretty much this is what you have to do.



回答2:

If you didn't want to create a profile that you have to maintain (eg: checking in to source control, etc), you could create the profile on the fly as follows:

Capybara.register_driver :selenium_firefox do |app|
  profile = Selenium::WebDriver::Firefox::Profile.new
  profile["extensions.update.enabled"] = false
  profile["app.update.enabled"] = false
  profile["app.update.auto"] = false
  Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
end

Capybara.default_driver = :selenium_firefox

That will create a profile on the fly that won't update the browser version or the extensions. Hope that helps!



回答3:

As I don't use Ubuntu I can only suggest my Windows workaround. I think it's a proper way to use a second Firefox profile without Plug- ins to run selenium tests.

In Windows that can be achieved by feeding "firefox.exe -ProfileManager -no-remote" to Windows Run.

A untested way for Ubuntu would be [Alt]+[F2] and firefox -ProfileManager. It's important to close all Firefox Windows and maybe kill still existing processes before



回答4:

This link might be able to help you : http://www.seleniumwiki.com/automation-tips/how-to-disable-add-ons-pop-up-for-custom-firefox-profile/