1

Trying to automate clicking on a link. "document.links[1].href" gives me the correct url, but "document.links[1].click()" has no effect.

Webpage has 4 tables on it. Based on another Stack Exchange post, I tried "document.querySelector('table a').click()" and that clicked the link associated with the first table. I want to click the link associated with the second table. 'table b' did not work.

I also saw a getElementByID approach, but in the code snippet below, I don't see an ID to use.

The second link/table, the one I want, is below.

"<table style=[STYLE].<tbody><tr><td><a href=[DESIRED URL] target="_blank">[LABEL]</a></td></tr></tbody></table>"

I would expect the link to be clicked, but instead nothing happens.

  • Does this answer your question? [How do I programmatically click a link with javascript?](https://stackoverflow.com/questions/902713/how-do-i-programmatically-click-a-link-with-javascript) – Obsidian Age Nov 11 '19 at 23:43
  • You also have a reverse tabnapping vulnerability. See [*this answer*](https://stackoverflow.com/a/50709760/2341603). – Obsidian Age Nov 11 '19 at 23:43
  • As to vulnerability, not my issue (it's not my site). As to the linked answer you provided, I don't see an ID to use the getElementByID function (if there's an ID, it would be in the code snippet I provided, right?). – user3723936 Nov 11 '19 at 23:49

0 Answers0