I am getting a no such element exception when I switch to other window to operate

61 Views Asked by At

when I switch to other window and I want to edit from text box then the xpath of text box giving no such element exception even xpath is correct

please guide me why I am getting a error

1

There are 1 best solutions below

1
Bhairu On
Probably, when an application takes you to another window to perform the remaining action so that time selenium control is still vested in the parent window, for that you have to switch to the window first to perform the remaining action. please follow the below line of codes to handle windows.

Set<Integer>Allwindows=driver.getwindowhandles();

for (int windowHandle:Allwindows) 
{
sysout("All windows"+windowHandle.size());
}
//Child window
driver.switchTo().windows(1);
//SwitchBack to Parent
driver.switchTO.windows(0);
}