Controlling new tab to operate using Watir? (Ruby)

為{幸葍}努か 提交于 2019-12-05 20:38:01

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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!