Selenium – change windows

23 Aug

Upgraded capybara to 2.1.x (with Selenium Webdriver) and my switch_to window calls started failing.

This is how i fixed it:

sleep(5)
page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
within_window(page.driver.browser.window_handles.last) do
   page.should have_content('My Text on New PopUP')
  page.driver.browser.close
end

Seems to take a lot of trial and error when these things break.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: