我正在尝试设置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会写入这个值吗?
发布于 2014-11-26 20:05:20
如果您使用的是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)
endhttps://stackoverflow.com/questions/27148624
复制相似问题