Jump to content

Issues with AutoLogin for Web


LucasZ
 Share

Recommended Posts

Hey everyone, so my problem is that I'm trying to setup a script that will automatically login to a website.  The site itself I think is my main challenge in that it takes a few seconds to load after even IE thinks it's fully loaded.  I've tried adding a sleep timer in to combat this, but it doesn't seem to help.  If I run the script initially it opens IE and then I get an error as follows:

Line 1784 (File "C:\Program Files (x86)\AutoIt3\IE.au3"):

Return SetError($_IESTATUS_Success, 0, $oObject.document)
Return SetError($_IESTATUS_Success, 0, $oObject^ ERROR

Error:  The requested action with this object has failed.

The script I have is as follows:

#include <IE.au3>

Local $url = "http://website" ;This is the actual website address
Local $oIE = _IECreate ( $url, 1)

;Sleep(10000)

_IELoadWait($oIE)

Local $oForm = _IEFormGetCollection($oIE, 0)

$oQuery1 = _IEFormElementGetObjByName ($oForm, "x-auto-12-input")

$oQuery2 = _IEFormElementGetObjByName ($oForm, "x-auto-13-input")

$TargetUsername = "Yourusername"

$TargetPassword = "yourpassword"

_IEFormElementSetValue ($oQuery1,$TargetUsername)

_IEFormElementSetValue ($oQuery2,$TargetPassword)

$oButton=_IEGetObjById($oIE,"")

_IEAction ($oButton, "click")

_IELoadWait($oIE,0)

If, when the initial script errors out, I run the script a second time without closing the browser window the user name and password both populate without issue.  The button click is another story, but until I can get the username and password to load on the initial script run I won't worry about that.

I'm not entirely sure why the status can't be read and even if I take out the _IELoadWait($oIE) it doesn't seem to really help.  Any help would be greatly appreciated.  I'm just not sure what the deal is.

Edited by LucasZ
Link to comment
Share on other sites

Also, if I use the following script instead, it seems to avoid the error and does properly navigate tot he site, but then won't enter the credentials specified:

#include <IE.au3>

Local $url = "actualurl"
Local $oIE = _IECreate()

_IELoadWait($oIE)

_IENavigate ($oIE, $url, 1)

_IELoadWait($oIE)

Sleep (5000)

Local $oForm = _IEFormGetCollection($oIE, 0)

$oQuery1 = _IEFormElementGetObjByName ($oForm, "x-auto-12-input")

$oQuery2 = _IEFormElementGetObjByName ($oForm, "x-auto-13-input")

$TargetUsername = "Yourusername"

$TargetPassword = "yourpassword"

_IEFormElementSetValue ($oQuery1,$TargetUsername)

_IEFormElementSetValue ($oQuery2,$TargetPassword)

$oButton=_IEGetObjById($oIE,"")

_IEAction ($oButton, "click")

_IELoadWait($oIE,0)

Link to comment
Share on other sites

I'm not really getting any errors, it's just not inputting the credentials.  The code is:

 

#include <IE.au3>

Local $url = "actualurl"
Local $oIE = _IECreate()
Local $TargetUsername = "Yourusername"
Local $TargetPassword = "yourpassword"

;_IELoadWait($oIE)

_IENavigate ($oIE, $url, 1)

$oIE = _IEAttach ( "title" ) ;also tried with URL instaed of title and Local $oIE = _IEAttach ( "title or url" )

_IELoadWait($oIE)

Local $oForm = _IEFormGetCollection($oIE, 1)

$oQuery1 = _IEFormElementGetObjByName ($oForm, "x-auto-12-input")

$oQuery2 = _IEFormElementGetObjByName ($oForm, "x-auto-13-input")

_IEFormElementSetValue ($oQuery1,$TargetUsername)

_IEFormElementSetValue ($oQuery2,$TargetPassword)

;$oButton=_IEGetObjById($oIE,"")

;_IEAction ($oButton, "click")

;_IELoadWait($oIE,0)

 

Of course, the page comes up, the website appears, but nothing will enter in.

Edited by LucasZ
Link to comment
Share on other sites

I haven't written anything using ie.au3 library for a long time but try to mess with these functions.

_IEGetObjById\_IEGetObjByName  + IEPropertySet("innertext or innerhtml")

 

as far as i remember _IEForm does not always function with forms.

Edited by Au3Builder
Link to comment
Share on other sites

I honestly wanted to make this a more sophisticated script, but since I was having these issues as specified and without spending a ton of time sending out logs and everything else I just decided to go with the less sophisticated version of the script as follows:

 

#include <IE.au3>

Local $url = "actualrul"
Local $oIE = _IECreate ($url, 1)

$TargetUsername = "Yourusername"

$TargetPassword = "yourpassword"

_IELoadWait($oIE)

Sleep (5000)

Send ($TargetUsername)

Send ("{TAB}")

Send ($TargetPassword)

Send ("{ENTER}")

 

This seems to work as desired.  

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...