WebPagetest Forums
Navigation Error when scripting - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: WebPagetest (/forumdisplay.php?fid=7)
+--- Forum: Bugs/Issues (/forumdisplay.php?fid=10)
+--- Thread: Navigation Error when scripting (/showthread.php?tid=15684)



Navigation Error when scripting - MadCowMoo - 02-23-2019 08:48 AM

I've tried a variety of techniques to log in to a website using scripting. For example:

logData 1
SetEventName Goto Login
navigate https://www.example.com/secure/login
logData 1
SetEventName Set Username
setValue id=username testUser
logData 1
SetEventName Set Password
setValue id=password password
logData 1
SetEventName Submit Form
clickAndWait id=signInBtn
//execAndWait document.forms[0].querySelector('button[id=signInBtn]').click()
//submitForm id=signInForm

The id values are correct, I've checked multiple times. Every step after "Goto Login" results in "Error: Navigation Error". Obviously, it fails to log in -- If I finish the script off with a "navigate" to a page only accessible by logged in users, I'm sent to a generic, non-logged in page. What is going on?


RE: Navigation Error when scripting - MadCowMoo - 02-26-2019 06:56 AM

IFrames. Stupid IFrames. If you find your way to my post, above, with similar issues, I would bet that your page has IFrames. In my case, my IFrame is coming from the same domain as the browser page -- if this is not the case for your IFrame, I'm not sure if this will work or not.

To access elements in the IFrame, I had to forget "setValue", "clickAndWait", and so on. I had to go straight to Javascript. It will look something like these examples:

exec document.querySelector("iframe[id=stupidIFrameId]").contentDocument.querySelector("input[id=password]").value = 'password'

execAndWait document.querySelector("iframe[id=stupidIFrameId]").contentDocument.querySelector("button[id=signInButton]").click()