Oryx2046 Posted March 28, 2013 Share Posted March 28, 2013 Hello all,First off, let me apologize if this is a dumb question. I've been digging through these forums all morning hoping that I could resolve this myself but I can't seem to figure it out. So for a work project I have a website I need to auto-login (via IE 8) and then navigate to a specific page to be displayed on a monitor.The code I have thus far is as follows:#include <IE.au3> Local $oUser, $oPass, $oSubmit Local $sUser = "myuser" Local $sPass = "mspass" Local $url = "http://10.10.10.10:8080/login/" Local $oIE = _IECreate($url) _IELoadWait($oIE) $oInputs = _IETagNameGetCollection($oIE, "input") for $oInput in $oInputs if $oInput.type = "text" And $oInput.name = "j_username" Then $oUser = $oInput if $oInput.type = "password" And $oInput.name = "j_password" Then $oPass = $oInput if $oInput.type = "submit" And $oInput.value = "Log In" 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)This code will successfully launch IE and navigate to the page I want. I went with the _IETagNameGetCollection because the "submit" button doesn't give a name or ID, so I couldn't use the _IEGetObjByName or ID. I did find a link to the IE Debug toolbar, and I have used that to verify that all of these fields/controls are of the correct type and that I'm using the correct names/values. I tried the AutoIt 1-2-3 examples, have watched youtube videos, tried some tutorials for IE from the forums, but I can't seem to get this working.The specific problem I have when I try to run is:C:\Documents and Settings\user\Desktop\test.au3 (19) : ==> Variable must be of type "Object".:$oUser.value = $sUser$oUser^ ERRORIt's my understanding this is because my variable isn't an object, but I can't understand why? I only started using AutoIt this morning, and I'm trying to get this script working in 4 hours, LOL (not my choice of deadline). Any assistance would be very appreciated, I just can't see where I'm going wrong here. Link to comment Share on other sites More sharing options...
jdelaney Posted March 28, 2013 Share Posted March 28, 2013 (edited) It's possible that the variable is not being set. Maybe durring the loop, it's never defined. Do some error handling with IsObj() You can also put this line at the top, and then the function for com-error handling (more info on failure) $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Func _ErrFunc($oError) ; Com error handling ; Do anything here. ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _ "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ "err.description is: " & @TAB & $oError.description & @CRLF & _ "err.source is: " & @TAB & $oError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF) EndFunc ;==>_ErrFunc post one of the nodes Edited March 28, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
DaleHohm Posted March 28, 2013 Share Posted March 28, 2013 I'd suggesting adding a debug line to your loop to see if you are even working on the set of objects you think you are... ConsoleWrite(_IEPropertyGet($oInput, "outerhtml")) & @CRLF) 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 More sharing options...
Oryx2046 Posted March 28, 2013 Author Share Posted March 28, 2013 I'd suggesting adding a debug line to your loop to see if you are even working on the set of objects you think you are...ConsoleWrite(_IEPropertyGet($oInput, "outerhtml")) & @CRLF)DaleHi Dale, thanks for the response! I tried adding that in at the top of the loop so I'd see it for each iteration, but it doesn't seem to be outputting to my console window. So then I tried just ConsoleWrite("1") inside of the loop and still got no output. So from that I'm guessing it must never enter the loop, which must mean there are no items in the collection?I am not sure how that's possible, because in the IE Debug toolbar I can see all these tagged as input:I'm not very familiar with website/webpage design, but is there something in your knowledge that I might look for?Thank you again!!! Link to comment Share on other sites More sharing options...
Oryx2046 Posted March 28, 2013 Author Share Posted March 28, 2013 (edited) Hi Dale, thanks for the response! I tried adding that in at the top of the loop so I'd see it for each iteration, but it doesn't seem to be outputting to my console window. So then I tried just ConsoleWrite("1") inside of the loop and still got no output. So from that I'm guessing it must never enter the loop, which must mean there are no items in the collection? I am not sure how that's possible, because in the IE Debug toolbar I can see all these tagged as input: I'm not very familiar with website/webpage design, but is there something in your knowledge that I might look for? Thank you again!!! Hey guys, so it looks like it was due to having a frame with a form inside of it. So basically I had to get the frame, then get the form, then get the collection of controls on the form. Once I did that, it's now working and auto-logging in just fine! Thanks for the pointers! Here's what I have that's working: #include <IE.au3> Local $oUser, $oPass, $oSubmit Local $sUser = "myuser" Local $sPass = "mypass" Local $url = "http://10.10.10.10:8080/login/" Local $oIE = _IECreate($url) _IELoadWait($oIE) $oFrame = _IEFrameGetCollection($oIE, 0) $oForm = _IEFormGetCollection($oFrame, 0) $oInputs = _IETagNameGetCollection($oForm, "input") for $oInput in $oInputs if $oInput.type = "text" And $oInput.name = "j_username" Then $oUser = $oInput if $oInput.type = "password" And $oInput.name = "j_password" Then $oPass = $oInput if $oInput.type = "submit" And $oInput.value = "Log In" 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) Edited March 28, 2013 by Oryx2046 Link to comment Share on other sites More sharing options...
Blue_Drache Posted March 28, 2013 Share Posted March 28, 2013 1. Do not ask for help with AutoIt scripts, post links to, or start discussion topics on the following subjects:Bypassing of security measures - log-in and security dialogs, CAPTCHAs, anti-bot agents, software activation, etc. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 28, 2013 Moderators Share Posted March 28, 2013 Blue_Drache,Correct. But this is not a dialog - looks like a normal page as far as I can see. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Oryx2046 Posted March 28, 2013 Author Share Posted March 28, 2013 Blue_Drache,Correct. But this is not a dialog - looks like a normal page as far as I can see. M231. Do not ask for help with AutoIt scripts, post links to, or start discussion topics on the following subjects:Bypassing of security measures - log-in and security dialogs, CAPTCHAs, anti-bot agents, software activation, etc.And if it helps, I own the webserver I'm logging into, so I'm not really bypassing so much as tailoring the application for a specific use. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 28, 2013 Moderators Share Posted March 28, 2013 Oryx2046, That makes no difference at all as the required code would be generic and so available for others to use on other sites. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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