【问题标题】:Xpath: Getting preceding span element where a button contains specific textXpath:获取按钮包含特定文本的先前跨度元素
【发布时间】:2021-04-29 15:21:49
【问题描述】:

尝试根据下面的 xpath 选择器获取带有 span 和文本等于“删除”的按钮,以便稍后单击

//text()='Delete'//preceding::span

但它不起作用。 html如下。如何获取点击的前一个元素?

<oj-button :class="[['button-' + actionButton.data.style]]" chroming="full" on-oj-action="[[(event) => { handleActionButtonItem(
                  properties.actionButtons.menuItemAction,
                  actionButton.data.action,
                  properties.details
                )}]]" class="button-warn oj-button oj-button-full-chrome oj-button-text-only oj-enabled oj-complete oj-default">

                <!--oj-bind-text value='[[actionButton.data.name]]'--><!--ko text:actionButton.data.name--><!--/ko--><!--/oj-bind-text-->
              <div style="display: none;"></div><button class="oj-button-button" aria-labelledby="_ojcustomelem2902|text"><div class="oj-button-label"><span><span class="oj-button-text" id="_ojcustomelem2902|text">Delete</span></span></div></button></oj-button>

【问题讨论】:

    标签: html xpath oracle-jet


    【解决方案1】:

    如果我理解正确,您正在寻找类似的东西

    //button[.//span['Delete']]
    

    在你的实际 html 上尝试一下,看看它是否有效。

    【讨论】:

      【解决方案2】:

      类似的东西

      //button[.//span[.='Delete']]
      

      或者如果那个跨度总是有 class="oj-button-text"

      //button[.//span[@class='oj-button-text' and .='Delete']]
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-01-03
        • 2018-08-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-18
        相关资源
        最近更新 更多