【问题标题】:How to fix iframes not working with Microsoft Edge?如何修复 iframe 不适用于 Microsoft Edge?
【发布时间】:2016-07-05 11:29:14
【问题描述】:

Change iframe 适用于 Firefox 网络驱动程序和 Chrome 网络驱动程序,但不适用于 Microsoft Edge 驱动程序。所有其他测试在 Edge 中运行良好,但没有更改 iframe。我更新了 Edge 驱动程序和 Windows 10,因为这是一个已知问题,但这仍然没有解决我的问题。有没有其他方法可以解决这个问题?

driver.switchTo().defaultContent(); 
driver.switchTo().frame("settingiframe");
driver.findElement(By.id("LibraryConfigurations")).click();

输出消息是:找不到这样的元素

【问题讨论】:

标签: javascript selenium iframe webdriver microsoft-edge


【解决方案1】:

您需要实现WebDriverWait 以等待可用的帧然后切换如下:-

WebDriverWait wait = new WebDriverWait(driver,20);

driver.switchTo().defaultContent();
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("settingiframe")); 

//after successfully switching to frame you need to wait until element to be clickable
WebElement el = wait.until(ExpectedConditions.elementToBeClickable(By.id("LibraryConfigurations")));
el.click();

注意:- 对于给定的frame,上述代码将wait最多20秒。如果frame 在给定时间内可用,它将切换到给定的frame。否则会抛出TimeoutException

希望对你有所帮助...:)

【讨论】:

    猜你喜欢
    • 2019-02-15
    • 1970-01-01
    • 2017-06-30
    • 2023-01-14
    • 1970-01-01
    • 2020-04-11
    • 2016-07-23
    • 1970-01-01
    • 2016-09-12
    相关资源
    最近更新 更多