Selenium webElement 属性 变化

Selenium webElement property change

我正在使用 selenium.There 自动化一个应用程序,没有像 id、tag 这样的普通标签,我可以通过它找到一个元素。所以我使用的是 xpath[driver.findElement(By.xpath())]。但是现在我发现 WebElement 的一些 xpath 在运行时动态变化,所以我的测试用例是 failing.Even 相对 xpath 选项不适用于 HTML.I 我正在粘贴 [=19] 的一部分=] 的 AUT。请让我知道如何处理这种情况。

<div>
<button class="btn btn-primary ng-hide" ng-click="unlockOrder('/content/boss/en/dashboard');" ng-show="enableUnlockButton" type="button">Unlock Order</button>
<button class="btn btn-primary" ng-click="discardOrder('/content/boss/en/create-order/pre-order-options');" type="button">Discard Order</button>
<button class="btn btn-primary" ng-click="saveOrder(showSaveButton && ban_search.$valid);" ng-disabled="showSaveButton==false || ban_search.$invalid" type="button" disabled="disabled">Save Order</button>
</div>

我会依赖按钮文本:

driver.findElement(By.xpath('//button[. = "Unlock Order"]'))

其中 . 指的是按钮的文本。