Jump to content

Having Trouble Validating Login Information In Ie


Recommended Posts

Hey guys... I'm using IE.au3, the IE functions from DaleHolm. What I'm trying to do is open up a window in IE, put the login information into the login form, and hit the submit button. The code I have does this, but the problem is... The information doesn't seem to be getting recognized by the server, or something... It just puts me back at the login screen.

If I hand-type the information on the site, it works fine. I've tried this on several websites that I have login information for, and I can't get it to work for any of them. Is this just a limitation of AutoIt? Here's my code:

$oLog = _IECreate ($logurl) ;Create IE Instance using the login URL
$oLogHWND = _IEPropertyGet ($oLog, "hwnd") ;Get the HWND of login URL
WinSetState ($oLogHWND, "", @SW_MAXIMIZE) ;Maximize the window
$oForm = _IEFormGetCollection ($oLog, 1)  
$oEmail = _IEFormElementGetObjByName ($oForm, "email")  
$oPassword = _IEFormElementGetObjByName ($oForm, "password")
_IEFormElementSetValue ($oEmail, $email) ;Set username
_IEFormElementSetValue ($oPassword, $password) ;Set password
_IEFormSubmit ($oForm) ;Login
Edited by Xealos
Link to comment
Share on other sites

if you have a look IEformgetcollection gets the stuff in the form IE Inputboxes and such (i think)

use

_IEFormGetObjByIndex() instead its based on a 0 index so 0 = 1 or use

_IEFormGetObjByName()

Well, the information is being entered correctly into the fields that I need it to go to... It's just that when _IEFormSubmit($oForm) executes, it doesn't actually log in. It just kind of reloads the page almost. As an example, I tried logging into Myspace with it, and all the information gets put into the right places, and it hits the login button... But the next page that loads is just the log in page again. It's strange.

Edited by Xealos
Link to comment
Share on other sites

here is mine to enter in www.libero.it :

#include <IE.au3>
$oIE = _IECreate()
$oIE.visible = 0
sleep(500)
_IENavigate($oIE, "http://www.libero.it/")
$oIE.visible = 1
sleep(100)
$oDoc = _IEDocumentGetObj($oIE)
$oForm = _IEFormGetObjByName($oIE, "webmail")
;$oForm= _IEFormGetObjByIndex($oIE, 3)
Sleep(500)
$oQuery = _IEFormElementGetObjByName($oForm, "Username")
$oQuery2 = _IEFormElementGetObjByName($oForm, "Password")
$oButton = _IEFormElementGetObjByName($oForm, "Act_Login")
;$oButton = _IEFormElementGetObjByName($oForm, "Entra")
;sleep(1000)
$indx =_IEFormElementGetObjByIndex($oForm,1)
$indx2 =_IEFormElementGetObjByIndex($oForm,2); @libero
$indx3 =_IEFormElementGetObjByIndex($oForm,3)
$indx4 =_IEFormElementGetObjByIndex($oForm,4)

;MsgBox(262144, "", $indx)
_IEFormElementSetValue($indx, "MYUSER")
_IEFormElementSetValue($indx3, "MYPASS")
;_IEFormElementSetValue($indx2, "libero")

;MsgBox(262144, "", _IEFormElementGetValue($indx2))
;Sleep(2500)
;$oIE.document.all.$indx2.value="libero"
;$oIE.document.all.choice.value = "libero"
_IEFormElementSetValue($indx2,"libero")

Sleep(500)
$oIE.document.all.Act_Login.Click 
#cs
;alt="Entra"
; _IEClickImg($o_object, "I Agree", "alt")
  _IEClickImg($oForm, $indx4, "src")
;_IEClickImg($o_object, $s_linkText, $s_mode = "src", $i_index = 0, $f_wait = 1)
$oButton2 = _IEFormElementGetObjByName($oForm, "entra")
MouseMove(741,484,0)
MouseClick("right",741,484,1,0)

#ce

This is a great tool made by DaleHohm in autoit to fetch web pages :

launch it and wait :

the same *.au3

Edited by Lapo
Link to comment
Share on other sites

If you are unaware that the index values are 0-based, then thatsgreat2345 could be right.

Another very common issue is that there is a Javascript onclick event bound to the Submit button that does extra processing that a FormSubmit would not perform.

To simulate this, get an object reference to the Submit button just as you did to the other form fields and then use _IEAction($oSubmit, "click") -- you'll then probably want to follow it up with an _IELoadWait to insure the window comes to rest before you attempt other functions.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

If you are unaware that the index values are 0-based, then thatsgreat2345 could be right.

Another very common issue is that there is a Javascript onclick event bound to the Submit button that does extra processing that a FormSubmit would not perform.

To simulate this, get an object reference to the Submit button just as you did to the other form fields and then use _IEAction($oSubmit, "click") -- you'll then probably want to follow it up with an _IELoadWait to insure the window comes to rest before you attempt other functions.

Dale

To be honest, I think the "index values are 0-based" thing might have gone over my head. :-\ I didn't think about there being a being a Javascript onclick event. I'll try that for sure. I feel somewhat stupid for not understanding thatsgreat2345's post. Heh. :">

Link to comment
Share on other sites

  • Moderators

To be honest, I think the "index values are 0-based" thing might have gone over my head. :-\ I didn't think about there being a being a Javascript onclick event. I'll try that for sure. I feel somewhat stupid for not understanding thatsgreat2345's post. Heh. :">

Its not over your head, your just thinking too hard about it. An index is just the number value given to an element on a webpage to help identify it. Lets say a webpage has three forms, each of these forms have an index number based on source order. The first forms index will be "0", the second "1", and the third "2". Hope that helps clear things up for you?
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...