Question

I have some automated tests that click on links in a web app. The automated tests run against an iOS Simulator browsing to web pages with Mobile Safari. The automation is driven by Appium and watir-webdriver.

I am having trouble with windows that open up after I click on links. I just want a way to return to the window I first started with or close all the new windows that have popped up during the course of a test.

I've tried: browser.windows[0].use to try and get back to the first window and browser.windows.last.close to try and get rid of windows that I don't want.

Any suggestions?

Was it helpful?

Solution

def close_windows
  while browser.windows.size > 1 
    browser.windows.last.close 
  end 
end

Calling close_windows function after clicking a link that opens in a new window should work. This may not be the greatest solution and only applies to ensuring the first browser is the sole one open. Not much an improvement upon your answer, but maybe cleaner.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top