In selenium webdriver, I am trying to click on a field in new window, but I keep getting error as
"Timed out after 20 seconds waiting for presence of element located by: By.xpath: .//*[@id='UpdatePanel1']/table/tbody/tr[2]/td/table/tbody/tr[1]/td Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55"
Here's the piece of code I have written. Kindly help
public class AE_Shipment {
public void AE_Shipment1() throws InterruptedException
{
MyClass1 M1= new MyClass1();
WebDriver w1 = M1.w;
w1.findElement(By.xpath(".//*[@id='MainMenu-mI001']")).click();
w1.findElement(By.xpath(".//*[@id='MainMenu-mI001-sM-mI001']/table/tbody/tr/td[2]")).click();
w1.findElement(By.xpath(".//*[@id='MainMenu-mI001-sM-mI001-sM-mI000']/table/tbody/tr/td[2]")).click();
w1.findElement(By.xpath(".//*[@id='MainMenu-mI001-sM-mI001-sM-mI000-sM-mI000']/table/tbody/tr/td[2]")).click();
WebDriverWait wait = new WebDriverWait(w1, 20);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//*[@id='UpdatePanel1']/table/tbody/tr[2]/td/table/tbody/tr[1]/td")));
w1.findElement(By.id("ButSearch")).click();
}
Update: I have tried switching to the new window using the code below but I get the same error.
String parentHandle = w1.getWindowHandle(); // get the current window handle
w1.findElement(By.xpath(".//*[@id='ButSearch']")).click();
for (String winHandle : w1.getWindowHandles())
{
w1.switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
}