【问题标题】:How to switch back to default content (or switch iframes) in Selenium IDE如何在 Selenium IDE 中切换回默认内容(或切换 iframe)
【发布时间】:2015-07-23 11:23:55
【问题描述】:

我必须浏览一个由框架构建的网站,有点像“一片特殊的雪花”

它最多包含 3 个 iframe,但只有一个是“活动的”,其他的被设置为显示:无。 每次我从一个页面移动到另一个页面时,新页面都会加载到另一个 iframe 中。

现在,如果我想访问新活动 iframe 中的元素,我会收到错误“找不到元素”

使用 Webdriver 我通过执行以下操作解决了问题

WebElement currentFrame = _driver.findElement(By
            .xpath("//iframe[not(contains(@style,'display: none'))]"));
_driver.switchTo().frame(currentFrame);
....
Driver.SwitchTo().DefaultContent();
....
WebElement currentFrame = _driver.findElement(By
            .xpath("//iframe[not(contains(@style,'display: none'))]"));
_driver.switchTo().frame(currentFrame);

在 Selenium IDE 中,我设法找到了我的第一帧

Command: selectFrame
Target: //iframe[not(contains(@style,'display: none'))]

但在这一点上我被卡住了。 如果我自己去单击命令序列一切都很好,但是当我尝试执行整个测试用例时,它在新 iframe 中找不到任何元素我什至尝试暂停,并等待 10 秒以防新框架还没有完成加载,但这并没有什么不同。

【问题讨论】:

  • 尝试目标:xpath=//iframe[not(contains(@style,'display: none'))]

标签: selenium selenium-ide


【解决方案1】:

看来我可以通过简单地切换到默认内容:

Command :selectWindow

没有目标,没有价值

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-24
    • 1970-01-01
    相关资源
    最近更新 更多