0 votes
1 view
in DevOps and Agile by (19.8k points)

So, with respect to integration testing using Capybara and RSpec, I know I can do this:

page.driver.browser.manage.window.resize_to(x,y)

per How to set Browser Window size in Rspec (Selenium) for specific RSpec tests, but is there a way to do this globally so that every test that is affected by media queries doesn't have to define this?

1 Answer

0 votes
by (63.4k points)

For test runtime in Capybara 2.2.4 version, you can achieve this by doing

before do

  handle = Capybara.page.driver.current_window_handle

  Capybara.page.driver.resize_window_to(handle, height, width)

end

Or

before do   

  Capybara.page.current_window.resize_to(height, width)

end

If you encounter an error like this "Capybara::NotSupportedByDriverError: Capybara::Driver::Base#current_window_handle" I suggest you change your WebDriver

before do   

  Capybara.page.current_window.resize_to(height, width)

end

scenario js: true do

  # your test here

end

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...