String Parentwindow = driver.getWindowHandle();
driver.findElement(By.xpath("//*[@id='ImageButton5']")).click();
Thread.sleep(3000);
for(String winHandle : driver.getWindowHandles()){
driver.switchTo().window(winHandle);
Thread.sleep(3000);
}
System.out.println("Title of the page after - switchingTo: " + driver.getTitle());
driver.findElement(By.id("txtEnterCptCode")).sendKeys("99219");
//Thread.sleep(3000);
driver.findElement(By.id("btnSearch")).click();
Thread.sleep(3000);
driver.findElement(By.id("chklstAllprocedure_0")).click();
Thread.sleep(3000);
driver.findElement(By.id("btnOk")).click();
Thread.sleep(5000);
/*ALL MODIFIERS 1*/
driver.switchTo().window(Parentwindow);
System.out.println(driver.getTitle());
//Thread.sleep(4000);
driver.switchTo().frame("ctl00_ContentPlaceHolder1_iframeID1");
Thread.sleep(3000);
driver.findElement(By.xpath("//*[@id='ImageButton17']")).click();
Thread.sleep(3000);
for(String winHandle1 : driver.getWindowHandles()){
driver.switchTo().window(winHandle1);
Thread.sleep(3000);
}
System.out.println("Title of the page after - switchingTo: " + driver.getTitle());
driver.findElement(By.id("txtEnterModifier")).sendKeys("RT");
Thread.sleep(3000);
driver.findElement(By.id("btnSearch")).click();
Thread.sleep(3000);
driver.findElement(By.id("chklstAllModifiers_0")).click();
Thread.sleep(3000);
driver.findElement(By.id("btnOk")).click();
Thread.sleep(3000);
这是我的代码。有时当我尝试在父窗口和子窗口之间切换时,我的代码运行良好且没有错误,有时它会显示以下错误消息:
"Exception in thread "main" org.openqa.selenium.NoSuchWindowException: Unable to get browser (WARNING: The server did not provide any stacktrace information).
Command duration or timeout: 14 milliseconds".
请帮我解决这个问题。提前致谢。