Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Search then Click on Element
#2
Hi,

Not sure yet how-to do this.

I can get the button object in javascript like so:
Code:
var downloadButton; downloadButton = document.getElementsByClassName("mega-button positive js-default-download js-standard-download");

but that doesn't mean I can invoke a click on it as the button object does not have the method.

Next up I tried:
Code:
function simulateClick() {   const event = new MouseEvent("click", {     view: window,     bubbles: true,     cancelable: true,   });   const cb = document.getElementsByClassName("mega-button positive js-default-download js-standard-download");   const cancelled = !cb.dispatchEvent(event);   if (cancelled) {     // A handler called preventDefault.     alert("cancelled");   } else {     // None of the handlers called preventDefault.     alert("not cancelled");   } }
which then gave me "Uncaught TypeError: cb.dispatchEvent is not a function"

So for the moment I don't know.
--
Wil
Reply


Messages In This Thread
Search then Click on Element - by maddire - 2024-01-07, 21:45:24
RE: Search then Click on Element - by wila - 2024-01-08, 11:50:39
RE: Search then Click on Element - by wila - 2024-01-09, 14:33:46

Forum Jump:


Users browsing this thread: 1 Guest(s)