Sign in to follow this  
Followers 0
schachinger40

Simple _IEFormSubmit qustion

4 posts in this topic

#1 ·  Posted (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] & @CRLF

ConsoleWrite($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 by schachinger40

Share this post


Link to post
Share on other sites



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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0