1

I am trying to click a button in Selenium for a script but first I'm trying to click the button using JavaScript in the chrome console, however this is proving difficult compared to other sites.

I have tried .click, .trigger ("click") and many more.

Element Source code:

<paper-icon-button icon="festify:favorite-border" title="Vote for Eastside (with Halsey &amp; Khalid)" role="button" tabindex="0" aria-disabled="false"></paper-icon-button>

Example of tested JS:

document.getElementsByTagName("paper-icon-button").click();
VM1691:1 Uncaught TypeError: document.getElementsByTagName(...).click is not a function
    at <anonymous>:1:52

The result of the JavaScript should be the button triggering it's event handler.

Can anyone make any suggestions?

Website in question - https://festify.us/party/-LN2ZKzoRy0eE_BP-R9k - (not my queue for obvious reasons)

Flatego
  • 11
  • 1

1 Answers1

1

As the function says, document.getElementsByTagName returns a list of elements, even if that list contains only one element.

If you expect to get only one element, do something like document.getElementsByTagName(...)[0].click(). Otherwise, loop over the list and execute element.click() on each element.

Ruben Helsloot
  • 12,582
  • 6
  • 26
  • 49