【问题标题】:How to use Click Button Keyword for Mat-Icons?如何为 Mat-Icons 使用 Click Button 关键字?
【发布时间】:2019-05-06 07:02:19
【问题描述】:

如何为 Mat-Icons 使用 Click Button 关键字? Selenium 库单击按钮关键字定位器包含唯一的名称、id、值,但是当我们在应用程序中检查 CSS 元素时,我们看不到名称、id、值,我们可以在检查的 CSS 元素中看到唯一的类。

<a _ngcontent-c5="" class="d-flex flex-grow-0 align-items-center p-3 download-button" mattooltip="Download this Robot" mattooltipposition="left" aria-describedby="cdk-describedby-message-0" cdk-describedby-host=""><mat-icon _ngcontent-c5="" class="mx-1 clickable mat-icon material-icons" role="img" aria-hidden="true">archive</mat-icon></a>[css [XPath locator][1]locator][1]

【问题讨论】:

  • 可以分享HTML代码吗?到目前为止你尝试过什么?
  • archive 是一个按钮??
  • 存档是 Mat-Icon 名称
  • 如何在 Robot Framework 中使用单击 Mat-Icon 按钮下载 Zip 文件夹或文件
  • 测试用例会通过但Zip文件夹没有下载

标签: selenium robotframework


【解决方案1】:

你可以试试这个xpath:

//a[@mattooltip]/mat-icon[text()='archive']

css 选择器是:

a[mattooltip] mat-icon[class*='mat-icon']

只要确保这些在 DOM 中应该是唯一的

【讨论】:

    【解决方案2】:

    这对我有用

      *** Settings ***
      Library  SeleniumLibrary   implicit_wait=10
    
      ***keywords ***
    
     Click Element  xpath://a[@mattooltip]/mat-icon[text()='archive']
    

    【讨论】:

    • 谢谢!,我想给你什么功劳?抱歉,我没看懂你的评论。
    猜你喜欢
    • 2019-02-01
    • 2015-12-09
    • 1970-01-01
    • 2020-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-21
    相关资源
    最近更新 更多