Eclipse XPath元素按钮位置



我无法通过xpath或其他选项找到此元素。

<button tabindex="0" class="jss65 jss59" type="button">
   <span class="jss64">
      <svg class="jss68" focusable="false" viewBox="0 0 24 24" aria-hidden="true" role="presentation">
         <path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"></path>
         <path fill="none" d="M0 0h24v24H0z"></path>
      </svg>
   </span>
   <span class="jss77"></span>
</button>```

您可以使用相对 xPath 找到此按钮。 例如,在定位此元素时,以下相对 xPath 对我有用:

//button[@class="jss65 jss59"]

有关如何自定义相对 xPath 的更多信息,我鼓励阅读本文:https://www.guru99.com/xpath-selenium.html

但是,就

个人而言,如果您选择更改此元素,我强烈建议在<button>标签中使用id。这样,您可以选择按 id 而不是依赖 xPath 来查找元素。 由于id被设计为每页始终是唯一的,因此在查找元素时,它通常可以通过 xPath 成为更简单、更可靠的解决方案。

最新更新