【问题标题】:I want to Automate on Active Inactive Buttons with this aria-hidden="true"我想用这个 aria-hidden="true" 自动处理活动的非活动按钮
【发布时间】:2019-09-26 07:16:38
【问题描述】:

想要点击具有以下 CSS 的 web 表格上的 Active inactive 按钮

尝试使用//td[contains(text(),'100003')]/following-sibling::td/div/ul/li/a/i[@id='active'] xpath

<i _ngcontent-c9="" aria-hidden="true" class="mat-icon material-icons ng-star-inserted" id="inactive" mattooltip="Activate" aria-describedby="cdk-describedby-message-14" cdk-describedby-host="" style="touch-action: none; user-select: none; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);">public</i>


<i _ngcontent-c9="" class="mat-icon material-icons ng-star-inserted" id="active" mat-raised-button="" mattooltip="Suspend" aria-describedby="cdk-describedby-message-16" cdk-describedby-host="" style="touch-action: none; user-select: none; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);">public</i>

尝试使用//td[contains(text(),'100003')]/following-sibling::td/div/ul/li/a/i[@id='active'] xpath

【问题讨论】:

  • 您能否详细说明您的问题?什么是活动非活动按钮?举几个例子。

标签: java selenium testing automation


【解决方案1】:

除非这是一个错字,否则标签的&lt;i _ngcontent-c9 部分可能会关闭 XPath 选择器。尝试用* 替换i 标签:

//td[contains(text(),'100003')]/following-sibling::td/div/ul/li/a/*[@id='active']

由于您尚未发布页面源的其余部分,因此我无法验证问题是否与路径的任何其他部分有关。如果此解决方案不起作用,请发布其他页面源信息和您收到的任何错误消息,以便我们更好地为您提供帮助。

【讨论】:

    【解决方案2】:

    正如 Christine 指出的那样,如果没有额外的页面源,很难确认任何解决方案,但假设 id 'active' 确实是唯一的(它应该是,但我过去看到过糟糕的 html),你可以使用:

    //i[@id='active']
    

    【讨论】:

      猜你喜欢
      • 2012-03-27
      • 2015-04-14
      • 2015-04-29
      • 1970-01-01
      • 1970-01-01
      • 2017-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多