schachinger40 Posted November 1, 2011 Share Posted November 1, 2011 (edited) Hello, I am in the process of writing my first script so I am still pretty green. I want to simply open IE, navigate to a webpage, enter in my credentials, hit submit then loop. It all works fine until submit. It inputs the crdentials but It doesnt submit the form and I receive no error. Here are the elements I am currently working with on the form. Form<form name="form1" action="login.cgi" method="POST" onsubmit="encrypt();"> Submit button<input type="submit" value="Login"> User name <input name="userid_work" type="text" size="50"><input name="userid" type="hidden" value=""> Password<input name="password_work" type="password" size="50"><input name="password" type="hidden" value=""> I am not concerned with the FOR LOOP function at the moment (notice it's commented out) and the reason I have two user id and passwords is because of a hidden base64 value in the form.#include <array.au3>#include <IE.au3> $text = FileRead("C:\printers.txt")$myArray = StringSplit($text, @CRLF, 1)For $i = 1 to $myArray[0] & @CRLFConsoleWrite($myArray[$i] & @CRLF)Next;For $i = 1 to $myArray[0]$printer = "5601R-IT5" ;$myArray[$i]$oIE = _IECreate( "http://" & $printer & "/web/guest/en/websys/webArch/mainFrame.cgi")_IENavigate ($oIE, "http://" & $printer &"/web/guest/en/websys/webArch/authForm.cgi") $oForm = _IEFormGetObjByName ($oIE, "form1")$oQuery = _IEFormElementGetObjByName ($oForm, "userid_work")$oQuery1 = _IEFormElementGetObjByName ($oForm, "password_work")$oQuery2 = _IEFormElementGetObjByName ($oForm, "password")$oQuery3 = _IEFormElementGetObjByName ($oForm, "userid") Sleep(2000)_IEFormElementSetValue ($oQuery3, "username example")_IEFormElementSetValue ($oQuery2, "password example")_IEFormElementSetValue ($oQuery1, "")_IEFormElementSetValue ($oQuery, "")Sleep(2000)_IEFormSubmit ($oForm) ;Next I am currently using AutoIt 3 on Windows 7 IE8. Thanks! Edited November 1, 2011 by schachinger40 Link to comment Share on other sites More sharing options...
water Posted November 1, 2011 Share Posted November 1, 2011 Please read the remarks in the help file for _IEFormSubmit: "For many HTML forms it is not sufficient to use _IEFormSubmit() because there is often custom Javascript tied to an onclick event for its Submit button ..." Maybe you need _IEAction as described in the remarks. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
schachinger40 Posted November 2, 2011 Author Share Posted November 2, 2011 Please read the remarks in the help file for _IEFormSubmit:"For many HTML forms it is not sufficient to use _IEFormSubmit() because there is often custom Javascript tied to an onclick event for its Submit button ..."Maybe you need _IEAction as described in the remarks. Thanks for your reply. Yes you are correct, that button is tied to a Java function. I tried doing _IEAction($oIE, "button title") but it keeps telling me there was no match. This is the button I am trying to target:<td class="defaultTableButton" onclick="javascript:execReset();; return false;" height="20"> <a href="javascript:execReset();" class="defaultTableCommandButton">OK</a> </td> And that Java Script is:<script language="Javascript" type="text/javascript">function execReset(){if(document.checkForm){document.form1.action = "setMachineReset.cgi";document.form1.method = "post";document.form1.target = "_self";document.form1.submit();} else {location.reload(true); This is my first script so I apologize if I am wasting anyone's time. Your help is greatly appreciated! BTW, in case you were wondering I am developing a script to reset multiple printers individually, by floor, by department or all of them. Link to comment Share on other sites More sharing options...
water Posted November 2, 2011 Share Posted November 2, 2011 Try this: $oIE = _IECreate( "http://" & $printer & "/web/guest/en/websys/webArch/mainFrame.cgi") ;.. all your other code $oSubmit = _IEGetObjbyname($oIE, "button title") _IEAction($oSubmit, "click") My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now