If i click on a button, i want to trigger another button selected by class.
I wrote the following HTML:
<button onclick="document.getElementsByClassName("frame-16nsqo4").click()">Click</button>
As I wrote in the comment document.getElementsByClassName("frame-16nsqo4") will return an array,thus document.getElementsByClassName("frame-16nsqo4").click() will not work
you need to get the element rather than array
So change
<button onclick="document.getElementsByClassName("frame-16nsqo4").click()">Click</button>
to
<button onclick="document.getElementsByClassName("frame-16nsqo4")[0].click()">Click</button>
.querySelector() which is in theory faster as it doesn't need to search the entire DOM as it can exit early as soon as it finds the first match, unlike getElementsByClassName which searches the entire DOMDocument.getElementsByClassName has the suffix getElements not getElement indicating that it's a collection/array
The getElementsByClassName method of Document interface returns an array-like object of all child elements which have all of the given class name(s).
Use
document.getElementsByClassName("frame-16nsqo4")[0].click()
or better use
document.querySelector(".frame-16nsqo4").click()
document.getElementsByClassNamewill return an array,so invokeclickwill not work