WebPagetest Forums
Calling JavaScript func - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: WebPagetest (/forumdisplay.php?fid=7)
+--- Forum: General Discussion (/forumdisplay.php?fid=25)
+--- Thread: Calling JavaScript func (/showthread.php?tid=15017)

Calling JavaScript func - samear - 08-23-2017 09:37 AM


I can no longer using the following script to log into our site because we use JavaScript functions instead.

logData 0
setValue id=username user1
setValue id=password password
submitForm name=loginForm

How would I put the following line in wpt scripting?

document.getElementById("__input1-inner").value = "username";
document.getElementById("__input2-inner").value = "password";



RE: Calling JavaScript func - andydavies - 08-24-2017 08:21 PM

exec and execAndWait are what you're looking for

exec document.getElementById("__input1-inner").value = "username";
exec document.getElementById("__input2-inner").value = "password";
execAndWait document.getElementById("loginForm").submit();

As per slide 38 (last line) of https://docs.google.com/presentation/d/1UgvmekxmQyrxGTgjWKa4s9OXiYXJ6oJTFis5wiC74Jk/edit#slide=id.g120a882107_0_124 I often grab the element for the submit button and send a click to it instead of using submit

RE: Calling JavaScript func - samear - 08-31-2017 03:46 AM

Thank you Andy!

Really helpful. it works!