I'm using watir for automated testing and after running through some tables, a chart then gets opened up in a new tab. But watir doesn't seem to recognise the new current tab and continues to search through the original browser tab.
Is there any way of telling watir which tab you want to be using?
Watir does not care if a new page opens in a new window or in a new tab, so use window switching API to switch to the new tab:
browser.window(:title => "annoying popup").use do
browser.button(:id => "close").click
end
More information: http://watirwebdriver.com/browser-popups/
You can use this code
browser.windows.last.use
this will set watir focus to newly or last opened tab or window, and after completion of use of this new tab/window just tell watir to close that tab/window
browser.windows.last.close
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