2

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
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Mads Cruz
  • 29
  • 6

2 Answers2

2

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();
Guy
  • 46,488
  • 10
  • 44
  • 88
0

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

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 2
    That locator is horrible. You have a massive string match... if any one of those classes changes or one is added or one is removed, the whole thing is broken. There's no need to use XPath here. It would be much better to use a CSS selector and avoid all this. – JeffC Oct 22 '18 at 18:38