所以我试着按下“审查协议”按钮:

它具有以下html代码:
<section class="col-33 text-right">
<button class="anchor-button bordered" ng-click="onClickReviewAgreement()">Review Agreement</button>
</section>但是很明显,它是从另一个资源加载的,所以findElement(By.*)不工作--我也尝试过By.xpath("/html/body/ul/li[2]/notification-bar/ul/li/section[1]/section[2]/button")-。我在View Page Sources中获得的所有相关代码是:
<!-- Agreement form modal -->
<ui-modal
ui-modal-id="ui.modals.agreementFormModal"
ui-modal-class="takeover agreement"
ui-modal-controller="AgreementFormController"
ui-modal-template-url="paths.templates + '/components/forms/tpl.agreement-form.html'"
ui-modal-has-dimmer="true">
</ui-modal>有办法选择这类元素吗?
发布于 2016-06-15 20:08:52
您应该能够使用css绑定到ng-click="onClickReviewAgreement()"。它应该是唯一的,css是xpath更好、更有效的替代方案。
发布于 2016-06-15 19:58:21
尝试使用css查找元素,然后单击-
WebElement buttonElement = driver.findElement(By.cssSelector('[ng-click="onClickReviewAgreement()"]'));
buttonElement.click();https://stackoverflow.com/questions/37844280
复制相似问题