Cannot click an icon within a div. Selenium Java

353 views Asked by At

code cannot find this icon wherein i have to click it i just notice that it is within a div. here is my sample code:

findLink(By.xpath("//div[@aria-label='Dashlet Actions' and contains(@ng-click,'updateActionMenu')]")).click

please see image for further information

enter image description here

2

There are 2 answers

5
undetected Selenium On BEST ANSWER

To click on the desired element you can use the following solution:

  • css:

    findLink(By.css("button.btn.btn-link[aria-label='Dashlet Actions']")).click
    
  • XPath:

    findLink(By.xpath("//button[@class='btn btn-link' and @aria-label='Dashlet Actions']")).click
    

Note: The element is an Angular element so you have to induce ExplicitWait for the desired element to be clickable

1
Amit Jain On

Use css selector to click.

driver.findElement(By.cssSelector(".btn.btn-link")).click();