【问题标题】:Couldn't find iframe on test case在测试用例上找不到 iframe
【发布时间】:2019-06-24 01:57:21
【问题描述】:

我有这个测试用例:

Select Frame    id=coach_frame63454108.cf1
Wait Until Element Is Visible       ${ap.gui.header.appname}
Page Should Contain Element         ${ap.gui.header.appname}
Page Should Contain Element         ${ap.gui.header.appnum}
Page Should Contain Element         ${ap.gui.header.procnum}

但总是出现以下错误:

Element with locator 'coach_frame63454108.cf1' not found.

iframe HTML 代码是:

<iframe id="coach_frame63454108.cf1" style="border: 0px; height: 100%; width: 100%; display: block" title="Verify Application"></iframe>  

谁能帮帮我。

【问题讨论】:

  • 尝试切换而不是选择,因为它是一个框架,或者如果.有问题,您可以尝试使用其他一些定位器,如xpath
  • @AliCSE 我已经尝试过其他定位器,结果是一样的。如何切换而不是选择
  • 你可以这样试试driver.switch_to.frame(driver.find_element_by_xpath("//iframe[contains(@id, 'coach_frame')]"'))
  • 要再次切换回主窗口,您可以尝试driver.switch_to.default_content()
  • 欲了解更多信息Refer This Link

标签: css selenium robotframework


【解决方案1】:

我也遇到过类似的问题,等待框架可见已经解决了,所以你可以尝试如下所示 -

Wait Until Element Is Visible    id=coach_frame63454108.cf1
Select Frame    id=coach_frame63454108.cf1
Wait Until Element Is Visible    ${ap.gui.header.appname}
Page Should Contain Element    ${ap.gui.header.appname}
Page Should Contain Element    ${ap.gui.header.appnum}
Page Should Contain Element    ${ap.gui.header.procnum}

另外,在选择框架之前,请确保取消选择任何先前选择的框架。

【讨论】:

  • 感谢您的帮助,但我已经尝试过了,但没有成功。错误是:元素 'id=coach_frame63454108.cf1' 在 5 秒后不可见。
【解决方案2】:

您可能需要先调用Unselect Frame,以重置主框架集 - 浏览器可能已经在一个框架中,在这种情况下,Select Frame 将寻找一个子框架。

【讨论】:

  • 感谢您的帮助,但我已经尝试过了,但也没有用。
猜你喜欢
  • 2019-07-23
  • 1970-01-01
  • 2018-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-22
  • 1970-01-01
相关资源
最近更新 更多