Skip to content

Instantly share code, notes, and snippets.

@pwlin
Created December 1, 2009 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pwlin/246483 to your computer and use it in GitHub Desktop.
Save pwlin/246483 to your computer and use it in GitHub Desktop.
javascript dispatch mouse event
var button = document.evaluate("//button[text()='archive']", document, null, XPathResult.ANY_TYPE,null).iterateNext();
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
button.dispatchEvent(evt);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment