【问题标题】:firefox profile setting not updating correctly through seleniumFirefox 配置文件设置未通过 selenium 正确更新
【发布时间】:2015-01-24 17:59:50
【问题描述】:

我正在尝试设置 firefox 配置文件,以便在运行我的 selenium 测试时所有链接都将在同一选项卡中打开。

我找到了执行此操作所需的设置,但是当程序运行时它没有设置为我想要的值,而其他值是。

这是我的代码

profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.link.open_newwindow.restriction'] = 0
profile['browser.link.open_newwindow'] = 1
@browser = Selenium::WebDriver.for :firefox, :profile => profile

加载的浏览器页面将“browser.link.open_newwindow”设置为 2,这不是默认设置,浏览器指示值 2 已由用户设置,即使它不是我设置的值是

有谁知道为什么会发生这种情况? selenium 或 page-object-gem 是否写入此值?

【问题讨论】:

  • 看起来 selenium 在启动时将其设置为 2,在文件 selenium/webdriver/firefox/extension/prefs.json 中是否可以以某种方式覆盖它?

标签: ruby firefox selenium page-object-gem


【解决方案1】:

如果您使用 Capybara,请在您的 features/support.env.rb 文件中添加此内容:

Capybara.register_driver :selenium do |app|
  profile = Selenium::WebDriver::Firefox::Profile.new
  profile['browser.link.open_newwindow.restriction'] = 0
  profile['browser.link.open_newwindow'] = 1
  Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
end

【讨论】:

  • 我不是,问题是特定于 ''browser.link.open_newwindow' 值,我可以设置的所有其他值都设置正确
猜你喜欢
  • 1970-01-01
  • 2021-02-13
  • 1970-01-01
  • 1970-01-01
  • 2016-03-27
  • 2013-02-14
  • 2016-08-28
  • 2017-08-07
  • 2016-06-25
相关资源
最近更新 更多