Selenium WebDriver : How do I set capabilities ele

2019-02-28 14:24发布

问题:

I have a rails app that uses selenium-webdriver (2.53.0). I am trying to overcome to the issue with Selenium (with a Firefox driver) where buttons that scroll under a static header get hidden. How do I set capabilities elementScrollBehavior to 1 for a FireFox configuration in rails?

I have this code:

profile ||= Selenium::WebDriver::Firefox::Profile.new 

回答1:

My environment isn't set up the same as yours but capabilities object needs to be set.

require 'selenium-webdriver'

Capybara.register_driver :selenium do |app|

  http_client = Selenium::WebDriver::Remote::Http::Default.new
  http_client.timeout = 120

  capabilities = Selenium::WebDriver::Remote::Capabilities.firefox( :elementScrollBehavior => 1 )

  Capybara::Selenium::Driver.new(
    app,
    :browser => :firefox,
    :desired_capabilities  => capabilities,
    :http_client => http_client
  )
end