Nicole Phillips
Nicole Phillips

Reputation: 763

Cannot click on a visible link

I am trying to click on a link which is located on an li list. Whenever I use a locator to find this element I get nothing in return. I've tried searching by element, the number id, chaining classes, etc. still coming up with nothing. I've noticed when I highlight the link with mouse the html changes and ads hovered to the code. Here is the .html without hover:

<li id="168283" class="jstree-leaf" rel="meetingSpace">

<ins class="jstree-icon">
    </ins>
<a class="" href="#" style="background-color: transparent;">
  <ins class="jstree-icon" style="background-color: transparent;">
        </ins>
  Salon A

</a>

</li>

the .html with hover:

<li id="168283" class="jstree-leaf" rel="meetingSpace">

<ins class="jstree-icon">
    </ins>
<a class="jstree-hovered" href="#" style="background-color: transparent;">
  <ins class="jstree-icon" style="background-color: transparent;">
        </ins>
  Salon A

</a>

</li>

I have to be honest I'm not great with .html but I'm learning, however this has thrown me for a loop

Some code I've tried:

element(by.xpath("//li[@id='168283']/a/ins")).click();
 //have tried by multiple different ways to find this element nothing.
element(by.css('a.jstree-clicked')).click();
element(by.id('168283')).click();

Upvotes: 2

Views: 192

Answers (2)

Majuj
Majuj

Reputation: 179

A small suggestion: have you tried to find your element with this?

element(by.linkText('Salon A')).click();

Upvotes: 1

user5278048
user5278048

Reputation: 36

Probably protractor is waiting for angular to settle down. Try clicking on element without waiting for angular like this -

browser.driver.findElement(by.xpath("//li[@id='168283']/a/ins")).click();

Or wait until element is visible before clicking it. Hope this helps.

Upvotes: 2

Related Questions