How to close all the windows before the next test in a test suite?

别来无恙 提交于 2019-12-06 12:29:30

Two ways you can do it

  1. In line with your technique using JS. You would first need to switch back to your first browser window (window_handle) and then perform "window.close()". (Not Preferred) (Not sure why its not working now for you, did you upgrade server version or different browser?)

  2. Simply use @driver.quit (Preferred)

Update


Just write this once. This will close all windows.

  after(:each) do
    @driver.quit
  end

If you want to close only one browser tab/window/popup, switch to that window_handle and then perform

@driver.close();

page.driver.browser.close closes current tab towards the end and the last (second) tab closes itself after each example.

in case if you are using cucumber, you can the use the BEFORE/AFTER hooks .please refer similar question on stackoverflow for some more on cucumber,please refer this Cucumber Hooks

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