使用硒时如何禁用Firefox中的附件 [英] How do I disable add-ons in firefox when using selenium

查看:64
本文介绍了使用硒时如何禁用Firefox中的附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Rails项目(在Ubuntu 10.04系统上)中使用Capybara硒,并且现在在运行测试firefox加载时刚刚升级了firefox,但是现在它已安装了所有附加组件,并且等待直到我第一次设置每个。

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?

是否可以设置所有加载项并保存设置,使其不会

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?

更新

如果我每次运行测试时都不会提示我吗?

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

我想用Firefox做测试。我已经在firefox下设置了一个测试配置文件,并尝试将其与以下内容一起使用:

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.

我正在使用水豚的git版本;

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)

我也尝试过使用Capybara.javascript_driver =:selenium_firefox_custom

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

推荐答案

尝试使用a自定义配置文件,并根据自己的喜好命名:

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

根据您使用的API版本可能已更改,但这几乎是你必须要做的。

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

这篇关于使用硒时如何禁用Firefox中的附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆