Search code examples
javaseleniumselenium-webdriverxpathkrypton

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


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

Solution

  • 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