无法使用selenium web驱动程序java切换回父帧?
driver.switchTo.framedriver.findElementBy.xpath/html/body/form/div[12]/div[1]/div[5]/iframe无法使用selenium web驱动程序java切换回父帧?,java,selenium,Java,Selenium,driver.switchTo.framedriver.findElementBy.xpath/html/body/form/div[12]/div[1]/div[5]/iframe new Select(driver.findElement(By.id("ddlFileExtensions"))).selectByVisibleText("DLA-Extension"); driver.findElement(By.cssSelector("opti
new Select(driver.findElement(By.id("ddlFileExtensions"))).selectByVisibleText("DLA-Extension");
driver.findElement(By.cssSelector("option[value=\"DLA-Extension\"]")).click();
driver.findElement(By.xpath("/html/body/form/div[3]/fieldset/table/tbody/tr[3]/td[2]/div[1]/input[1]")).sendKeys("TestDLA");
driver.findElement(By.xpath("/html/body/form/div[3]/fieldset/table/tbody/tr[4]/td[3]/a/input[1]")).click();
//Switch to new window opened
for(String winHandle : driver.getWindowHandles()){
driver.switchTo().window(winHandle);
}
driver.findElement(By.xpath("/html/body/form/div[3]/div[3]/div/table[1]/tbody/tr[1]/td[3]/a")).click();
driver.findElement(By.xpath("/html/body/form/div[3]/div[3]/div/table[10]/tbody/tr[2]/td[3]/a")).click();
driver.findElement(By.xpath("/html/body/form/div[3]/div[4]/a[1]/input[1]")).click();
driver.switchTo().frame(driver.findElement(By.xpath("/html/body/form/div[12]/div[1]/div[5]/iframe")));
//driver.findElement(By.xpath("/html/body/form/div[3]/div/a[1]/input[1]")).click();
mouseClickByLocation("/html/body/form/div[3]/div/a[1]/input[1]");
我的答案与你的代码不符。但我向你们展示了如何实现这一目标。只要确保代码中正确放置了所有步骤 步骤1:存储主窗口句柄 第二步:点击链接,打开新的浏览器窗口 步骤3:切换到新的打开的浏览器窗口 步骤4:返回主窗口
请尝试上载代码,该代码将显示您如何存储父窗口句柄并调用它。你上传的代码没有涵盖主要部分,这可能是你投反对票的原因。
String Parentwindow = driver.getWindowHandle( );
for ( String currentwindow : driver.getWindowHandles())
driver.switchTo( ).window(currentwindow);
{
// Perform your operations on the current window
driver.close( )
}
driver.switchTo().window(Parentwindow);