MartoRixel Posted June 28, 2015 Share Posted June 28, 2015 Hello guys,I am trying to write a simple script, which takes a few variables from an ini file, logs in into a website and then navigates the page to get some CSV report.So far so good. I just stumbled upon weird behavior of IE - after logging in it seems to have forgotten it's session.$oIE = _IECreate("https://www.reportsite.com/loginMain.page", 0, 1, 0, 1) _IELoadWait($oIE) $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput In $oInputs If $oInput.type = "text" And $oInput.name = "userIdDisplay" Then $oUser = $oInput If $oInput.type = "password" And $oInput.name = "password" Then $oPass = $oInput If $oInput.type = "image" Then $oSubmit = $oInput If IsObj($oUser) And IsObj($oPass) And IsObj($oSubmit) Then ExitLoop Next $oUser.value = $sUser $oPass.value = $sPass _IEAction($oSubmit, "click") _IELoadWait($oIE, 50) If _IEPropertyGet($oIE, "locationurl") = "https://www.reportsite.com/loginMain.page" Then ConsoleWrite("Timeout happened... logging in again" & @CR) $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput In $oInputs If $oInput.type = "text" And $oInput.name = "userIdDisplay" Then $oUser = $oInput If $oInput.type = "password" And $oInput.name = "password" Then $oPass = $oInput If $oInput.type = "image" Then $oSubmit = $oInput If IsObj($oUser) And IsObj($oPass) And IsObj($oSubmit) Then ExitLoop Next $oUser.value = $sUser $oPass.value = $sPass _IEAction($oSubmit, "click") EndIf _IELoadWait($oIE) $oIE = _IENavigate($oIE, "https://www.reportsite.com/allOrders.page", 1) _IELoadWait($oIE)At the beginning it was enough to just log in this way, go to the report page (allOrders.page) and navigate happily until the script downloaded the report.After a while, the page started to show a session-timeout error and just stayed on the log in page (loginMain.page). So I added a URL check and logged in again, if that happened.Now, as soon as I log in (without any problem) and try to navigate to allOrders.page, I am kicked out of the session again and being asked to log-in. Re-attaching $oIE again with the new address instead of navigating worked for a while, but not anymore.Can it be, that the $oIE object lost the session or did I write the code somehow, that $oIE after logging in refreshes it's session? Link to comment Share on other sites More sharing options...
Valuater Posted June 28, 2015 Share Posted June 28, 2015 Visually, I can see this error $oIE = _IENavigate($oIE, "https://www.reportsite.com/allOrders.page", 1) _IELoadWait($oIE)_IENavigate() has no return on Success8) Link to comment Share on other sites More sharing options...
JohnOne Posted June 28, 2015 Share Posted June 28, 2015 That is not strictly true Valuater, I have always found that _IENavigate returns -1 either upon success or failure.But of course you are correct about the IE object being destroyed when it gets assigned the return from _IENavigate. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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