I have a link that opens in a new window, and I need to test the part of my app that is within that new window.
Any suggestions will be much appreciated.
Define a step that contains this code:
page.driver.browser.switch_to.window (page.driver.browser.window_handles.last)
switch_to is a selenium command that allows you to change over to a new window window_handles returns a list of currently open windows
I realize this is a very old post, but here's a Cucumber step definition using Capybara and the Poltergeist driver:
And /^I follow "([^"]*)" to the new window$/ do |link|
new_window = window_opened_by { click_link link }
switch_to_window new_window
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With