I am trying to switch between two tabs and found following code
ArrayList<String> tabs2 = new ArrayList<String> (page.getWindowHandles());
System.out.println(tabs2.size());
page.switchTo().window(tabs2.get(1));
page.close();
page.switchTo().window(tabs2.get(0));
I have one doubt in this. My window is same so page.getWindowHandles()
is returning only one handle. tabs2.size
is 1 so page.switchTo().window(tabs2.get(1));
is giving exception ArrayIndexOutOfBound
I found similar code in this post switch tabs using Selenium WebDriver with Java but for me this code is giving exception.