我有4个与“ HOD”同名的文本,我想单击第一个“ HOD”。
我已经尝试了所有这些方法: 1 .// a [包含(text(),'HOD')] [1] 2.//a[@class="link_job ng-binding“] [1]
<ul type="none" class="job-search-results ng-scope" ng-if="flag && flag != undefined" id="ulId" ng-repeat="j in jobResult" xpath="1">
<!-- ngIf: j.statusId == 1 --><li ng-if="j.statusId == 1" class="job-small ng-scope"><a href="" class="big-a"></a><a href="" ng-click="fetchJobById(j.id);insertRecentSearch(j.position.id,'aaa')" class="link_job ng-binding">HOD</a>
<div class="ng-binding"><b>Department:</b> Computer_Science</div>
<div><b>Job Summary:</b> <p class="ng-binding">HOD should own masters degree in their onw field.
</p>
</div>
<img ng-src="resources/img/logo-placeholder.png" style="height:64px;" src="resources/img/logo-placeholder.png">
<!-- ngIf: j.status == 'Applied' -->
</li><!-- end ngIf: j.statusId == 1 -->
<!-- ngIf: j.statusId !=1 -->
</ul>
I expect that it should click on first HOD text.
答案 0 :(得分:1)
虽然设置延迟可以帮助它不是最好的方法。您可以等待直到看不到您的加载,然后尝试单击。这是一种快速的方法:
driver.wait(until.ElementIsNotVisible(driver.findElement(By.css('.loader'))));
driver.findElement(By.xpath('//a[contains(text(),'HOD') ][1]')).click();