JavaScript help needed to click a “kind of” link

I have a site that is behind a login, so I can't link right to it, but I'll try explain the problem.

On the right-hand side of each page is a list of "Tools" as shown here:

CleanShot 2021-03-14 at 21.07.48@2x

Until recently I was able to click that “E-mail” link by using “Click Safari link” but that is no longer working (the error message I get is "failed to find link 'E-mail').

I looked at the 'Inspector' to show the underlying HTML/JS which is here:

<a href="#" title="E-mail" class="email-link" data-panel="{&quot;Id&quot;:&quot;email&quot;,&quot;Url&quot;:&quot;delivery/emailpanel&quot;,&quot;Js&quot;:&quot;ep/controller/control/citationdeliverypanel.js&quot;}">E-mail</a>

I also tried:

document.getElementById('email').click()

but that did not work either.

I tried “Click at found image” which only works once but when I close one tab and ask it to look again, for some reason it does not find it.

This is a key feature of something that I do multiple times per week (like 5-30 times each time I use it), so any help would be appreciated.

Have you tried to copy any of these items in the Inspector?

Copy selector or Xpath will be two of the options.
image

See this:

copy xpath:

//*[@id="Column2Content"]/ul/li[4]/a

copy full xpath:

/html/body/form/div[2]/div[1]/aside/div/ul/li[4]/a

copy selector:

#Column2Content > ul > li:nth-child(4) > a

copy JS path

document.querySelector("#Column2Content > ul > li:nth-child(4) > a")

I'll tale a look at the macro you linked to. I don't even know what XPath is, to be honest.

(I used to know a lot about the web, but that was back when there was a lot less to know :slight_smile:

Update!

Oh! This worked:

Execute JavaScript:

document.querySelector("#Column2Content > ul > li:nth-child(4) > a").click()

That looks absurd to me, but as long as it works, I'm happy to accept it :slight_smile:

Try:

document.querySelector("#Column2Content > ul > li:nth-child(4) > a”).click();
1 Like

Ha! I was literally posting that as you wrote it. Thanks!

(I don’t know why my previous post had a “smart” quote in the JavaScript, but I’ve fixed it.)

1 Like