Running onclick JavaScript command using 'Inject JS Script'

Hi there,

There’s an automation that I’m building which requires clicking a link nested under 6 different levels of hidden HTML tags, in order to reach the target link I’m having to click on each HTML tag until I open all 6 levels, only just to click on the link.

The link I’m trying to click on has a piece of code written in javascript; the onlick looks like onlick=“javascript:code” whilst the href looks like this href=“javascript:enq(‘enq next.page’)”.

When I click on the link myself it opens up a new pop up with data I’m trying to reach, and I am also able to replicate this by running the function using Google Chrome’s Inpect Console. However, whenever I try to run this using “Inject Js Script”, it says “ReferenceError: enq is not defined.”

Could someone please kindly help me with this?

Many thanks in advance

@Mitesh_Sachania
does the link have an id?

e.g. .if the element is something like this
<a id = "abc" onclick = "....."></a>

then you can change your inject js function to:
document.getElementById("id").Click();

you can also use

document.getElementsByClassName
document.getElementsByTagName

etc

Hey @Mitesh_Sachania

Please show us the code of InjectJS ?

Thanks
#nK