我需要访问网页https://cloud.google.com/products/calculator-legacy上iframe id ="myFrame"内部的元素
我try 过这个解决方案,但不起作用:
By frameXpath = By.xpath("//iframe[@id='myFrame']");
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(20));
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(frameXpath));
WebElement frame = driver.findElement(frameXpath);
driver.switchTo().frame(frame);
我也try 过这个解决方案,但它也不起作用:
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//devsite-iframe/iframe")));
By frameXpath = By.xpath("//iframe[@id='myFrame']");
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(frameXpath));
driver.switchTo().frame(driver.findElement(frameXpath));
我有一个例外:
"NoSuchElementException: Unable to locate element: //iframe[@id='myFrame']"
是否有一种方法可以访问元素来设置估计的条件? 谢谢!