cannot choose a unique locator to click an element - selenium java krypton

107 Views Asked by At

I need to have a unique locator since i cannot use text because it both have facility, I need to click this

enter image description here

here is my sample code right now but it does not click

findLink(By.xpath("//*[ng-click()='promptGroupDrawerCtrl.closeDrawer()']")).click
2

There are 2 best solutions below

1
On BEST ANSWER

To click on the element with text as Facility you can use the following solution:

findLink(By.xpath("//a[@class='h4 panel-heading panel-back panel-title btn ng-binding' and contains(@ng-click,'closeDrawer')]")).click

Note: As the element is an Angular element you have to induce WebDriverWait for the desired element to be clickable

0
On

There are two problems with the xpath:

ng-click is an attribute, not a method. Remove the round brackets.

Attribute name should start with @

findLink(By.xpath("//*[@ng-click='promptGroupDrawerCtrl.closeDrawer()']")).click();