Java 无法切换到帧,即使我传递了正确的帧id或xpath,也找不到元素
url= 但我无法切换到这个帧。我找不到元素,除非Java 无法切换到帧,即使我传递了正确的帧id或xpath,也找不到元素,java,selenium,iframe,Java,Selenium,Iframe,url= 但我无法切换到这个帧。我找不到元素,除非 //WebElement frame = drive.findElement(By.xpath("//tr//td//iframe[@id='ifmail']")); //drive.switchTo().frame(drive.findElement(By.id("ifmail"))); //drive.switchTo().frame(drive.findElement(By.xpath("//iframe[@i
//WebElement frame = drive.findElement(By.xpath("//tr//td//iframe[@id='ifmail']"));
//drive.switchTo().frame(drive.findElement(By.id("ifmail")));
//drive.switchTo().frame(drive.findElement(By.xpath("//iframe[@id='ifmail']")));
这将在我切换到帧后发生
drive.findElement(By.xpath("//a[text()='Verify email']")).click();
iframe是
<iframe class="whc" frameborder="0" scrolling="auto" id="ifmail" name="ifmail" src=""></iframe>
听起来您需要等待iframe首先出现。在尝试切换到IFrame之前,请尝试webdriver等待
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("ifmail")));
html页面如下所示,这是什么编程语言?此外,您还应该编辑文章并添加Iframe HTML,而不是对其进行评论。同时提供完整的错误跟踪您需要打开此电子邮件吗?
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("ifmail")));