WebPagetest Forums
Scripting can't call javascript function before submit form - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: WebPagetest (/forumdisplay.php?fid=7)
+--- Forum: Bugs/Issues (/forumdisplay.php?fid=10)
+--- Thread: Scripting can't call javascript function before submit form (/showthread.php?tid=293)



Scripting can't call javascript function before submit form - wwtaotao - 07-02-2010 07:24 PM

I want to test my application by script, I wrote a script to login as below:

// load the account name and password
loadVariables accounts.txt

// bring up the login screen
setDOMElement name=user_id
navigate http://w3x32s05-pv010.pd.local

// log in
sleep 5
setValue name=user_id %ADMINISTRATOR%
setValue name=password %PASSWORD%
setDOMElement innerText=My Institution
sleep 5
submitForm name=login

It runs well but just couldn't login successfully.
After I debug code, I found the root reason is because the submitForm action won't run validate_form javascript funciton in my login page before submit(it will call the function if we submit it by manual).
my form is like this:
<form onsubmit="return validate_form( this, true );" method="POST" action="http://w3x32s05-pv010/webapps/login/" NAME="login" >
the validate_form javascript will encode the password by a token value, it means the encode password will change each time, I can't set the encode password value too.
Does it has any way I can write the script to login in my application? thanks.


RE: Scripting can't call javascript function before submit form - pmeenan - 07-02-2010 09:42 PM

Try sending a click (sendClick) to the form submit button instead of submitting the form itself.


RE: Scripting can't call javascript function before submit form - wwtaotao - 07-03-2010 12:54 AM

Thanks very much, I can run the script complete successfully now.


RE: Scripting can't call javascript function before submit form - rup - 03-19-2011 05:24 AM

hi,
I am testing login into live id and sign out. I am not able to login at all. After login page, I don't see it entering userid and pwd and submit. Please help fix my script.

navigate https://login.live.com
sleep 5
setValue name=login xxx1@hotmail.com
setValue name=passwd test
sleep 5
sendClick id=idSIButton9