【问题标题】:Robot Framework: How to select an HTML element located inside multiple iframes using Browser lib?Robot Framework:如何使用浏览器库选择位于多个 iframe 内的 HTML 元素?
【发布时间】:2022-12-28 16:09:28
【问题描述】:

正如浏览器库中所解释的那样,“有一个特殊的选择器 >>> 可用于组合 iframe 或框架集的选择器以及框架内元素的选择器”,例如:

Click Web Element Is Visible    iframe#iframe-example >>> //a[@onclick='buttonOK();']

如果我想选择“iframe-example”内的示例按钮,该示例工作正常。但是我怎样才能选择一个位于多个 iframe/frameset 中的元素呢?例如:

frameset >>> frame >>> iframe#iframe-example1 >>> iframe#iframe-example2 >>> //a[@onclick='buttonOK();']

选择这个元素的正确结构是什么?

我尝试了一些结构,但没有选择元素:

Click Web Element Is Visible    frameset >>> frame >>> iframe#iframe-example1 >>> iframe#iframe-example2 >>> //a[@onclick='buttonOK();']
Click Web Element Is Visible    frameset//frame[@id="example"]//iframe[@id="iframe-example1"]//iframe[@id="iframe-example2"]//a[@onclick='buttonOK();']

【问题讨论】:

    标签: html xpath iframe robotframework frameset-iframe


    【解决方案1】:

    试试Select frame关键字

    Select frame    //iframe[@id="example1"]
    Select frame    //iframe[@id="example2"]
    Wait until element is visible     //a[@onclick='buttonOK();']
    Click Element    //a[@onclick='buttonOK();']
    Unselect frame
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-13
      • 2019-12-03
      • 2017-04-14
      • 2017-11-28
      • 2019-11-17
      • 2019-02-18
      相关资源
      最近更新 更多