Saturday, 2 January 2016

How to work with multiple window in selenium




We can handle the multiple window by using below methods


getWindowHandle = used to point to parent window. Its return String

getWindowHandles = Its have collection of window which present at a time. Its return collection of string.



Below code for working with multiple window


String ParentWindow=driver1.getWindowHandle();   
for(String windowpopup:driver1.getWindowHandles())
{
driver1.switchTo().window(windowpopup);
System.out.println("Title of the current window"+driver1.getTitle();

}

driver1.switchTo().window(ParentWindow);

No comments:

Post a Comment