Salman
Salman

Reputation: 1853

Unable to click on a <a> tag- selenium

While trying to click on a link using Newrelic synthetic monitor(selenium based), it appears to have started failing since few days. The screenshot of error shows the control hovered over the link but didnt click.

.then(function() {
  log(10, 'clickElement "Dashboard"');
  return $browser.waitForAndFindElement(By.xpath('//*[contains(text()," Dashboard ")]'), DefaultTimeout); })
.then(function (el) { el.click();  })

Element:

<a _ngcontent-avd-c527="" cdkmonitorelementfocus="" rel="noopener noreferrer" queryparamshandling="merge" class="name trimmedTextWithEllipsis ng-star-inserted" href="**" target="_self" pbi-focus-tracker-idx="17"> Dashboard <!----><!----><!----><!----></a>

Upvotes: 0

Views: 101

Answers (1)

K. B.
K. B.

Reputation: 3690

My "favourite" automation issues. You can try:

  1. Check if the HTML has changed (new iframe or another anchor element that receives the click instead).
  2. Click more than once. Try double click.
  3. Try another type of click using the Actions class https://www.selenium.dev/documentation/webdriver/actions_api/mouse/
  4. Try to debug and if it is not reproducible in debug, it may be timing issue so you can try to wait a bit more.
  5. Investigate if it is a bug in the application you are testing.

Upvotes: 1

Related Questions