Close all browser with url : http://google.com

Hi @Elly_Tran,

Yes, do a loop over the list of browsers

Thank u

1 Like

Hi,

Should you do a loop over the list of browsers and then check if it is http://google.com or not? If yes, quit() that browser. If you want to close all browsers with no specific url, using closeApplication

The following closes all browser tabs that have “Google” in the URL and might get you started on your code. It basically loops until it tries to move to a window that does not exist which throws an exception. If you can find a statement that counts the number of tabs, then you can improve the routine immensely.

cnt = 0;
try {
    while (true) {
        WebUI.switchToWindowIndex(cnt)
	    String site = WebUI.getUrl()
	    if (site.contains("Google") || site.contains("google")) {
	        "close Google windows"
	        WebUI.closeWindowIndex(cnt)
	    } else {
	        cnt++
	    }
    }
} catch (Exception) {
	WebUI.comment("finished")
}
1 Like