0

I have 4 text with same name as 'HOD' and I want to click on first 'HOD'.

I have tried all these: 1.//a[contains(text(),'HOD') ][1] 2.//a[@class="link_job ng-binding"][1]

<ul type="none" class="job-search-results ng-scope" ng-if="flag &amp;&amp; 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.
Preeti
  • 7
  • 7

1 Answers1

1

While setting a delay can help it is not the best approach. You can wait until your loading is not visible and then try to click. Here is a quick approach:

driver.wait(until.ElementIsNotVisible(driver.findElement(By.css('.loader'))));
driver.findElement(By.xpath('//a[contains(text(),'HOD') ][1]')).click();
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
G. Kolev
  • 58
  • 5