我有切换到新窗口框架并执行任务的代码。但是在某些情况下,切换到新的窗口框架后,它就无法执行任务。该任务在其他计算机上有效,但在我的计算机上无效。
使用winhandle尝试了以下代码
//存储当前窗口句柄
// Perform the click operation that opens new window
driver.findElement(By.xpath("//a[@id='lnkSubmission']")).click();
Thread.sleep(3000);
// Switch to new window opened
for(String winHandle : driver.getWindowHandles()){
driver.switchTo().window(winHandle);
}
Thread.sleep(2000);
// Perform the actions on new window
driver.findElement(By.xpath("//input[@name='txtAccountName']")).sendKeys("test bbu");
I expect to perform the below code after switch
// Perform the actions on new window
driver.findElement(By.xpath("//input[@name='txtAccountName']")).sendKeys("test bbu");