javaseleniumxpathcss-selectorswebdriverwait

How can I find the exact text in browser automation using Selenium with Java?


<div data-ng-if="!newRequestReceived" class="ng-scope">
                <!-- ngIf: !authRequestCount --><p data-ng-if="!authRequestCount" class="ng-scope" style="" xpath="1">No more candidates awaiting Authorization</p><!-- end ngIf: !authRequestCount -->
                <!-- ngIf: authRequestCount -->
            </div>

I need help,

if find string like "No more candidates awaiting Authorization"

the loop will working How???

driver.findElement(By.xpath("//p[@class='ng-scope'][contains('No more candidates awaiting Authorization']"));

this is correct


Solution

  • To extract the string No more candidates awaiting Authorization you don't need a loop as such. As the element is an Angular element you need to induce WebDriverWait and you can use either of the following solutions: