FernanS1 Posted June 27, 2018 Share Posted June 27, 2018 (edited) Hi Guys, I'm having issues opening a specific link. My script is very simple (I am merely testing it out before I incorporate it into my other code). It opens the page just fine, but errors when I try to open the link. #include <IE.au3> Local $oIE = _IECreate("http://lc691wam.light.cos.local:7053/wamsp2/synergen/Logon?tgt=Main") Local $sMyString = "Login" Local $oLinks = _IELinkGetCollection($oIE) For $oLink In $oLinks Local $sLinkText = _IEPropertyGet($oLink, "innerText") MsgBox($MB_SYSTEMMODAL, "Title", $sLinkText, 10) Next The web page looks like this: The error I am getting is shown below: I am 90% sure it has something to do with the link (code works fine with any .com sites). Any insight would be great, ideally I don't wan't to use tabs or mouse clicks to maneuver through this site, but I'm not sure how to avoid this error. NOTE: Thanks so much! Shawn Edited June 27, 2018 by FernanS1 Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted June 27, 2018 Share Posted June 27, 2018 Good evening @FernanS1 I can't see the image of the error you are getting. Is it an AutoIt error? Best Regards. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
FernanS1 Posted June 27, 2018 Author Share Posted June 27, 2018 (edited) Hi @FrancescoDiMuro Apologies, I will post text & not images from here on out! The error says this: "C:\Program Files (x86)\AutoIt3\Include\IE.au3" (802) : ==> The requested action with this object has failed.: Return SetError($_IESTATUS_Success, $oObject.document.links.length, $oObject.document.links) Return SetError($_IESTATUS_Success, $oObject^ ERROR ->13:03:26 AutoIt3.exe ended.rc:1 It is an AutoIT Error Edited June 27, 2018 by FernanS1 Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted June 27, 2018 Share Posted June 27, 2018 (edited) @FernanS1 Thanks for the information Can I suggest you to insert an If...Else statement after calling every function which returns an @error code? Something like this: _IECreate(...) If @error Then ConsoleWrite("An error occurs on _IECreate. Error: " & @error & @CRLF) Else ; Instructions EndIf It helps a lot to understand where the error occurs in your script. Try, and post the result here Best Regards. Edited June 27, 2018 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
FernanS1 Posted June 27, 2018 Author Share Posted June 27, 2018 @FrancescoDiMuro Got the error! Local $oIE = _IECreate("http://lc691wam.light.cos.local:7053/wamsp2/synergen/Logon?tgt=Main") If @error Then ConsoleWrite("An error occurs on _IECreate. Error: " & @error & @CRLF) Else ; Instructions EndIf Local $sMyString = "overview" Local $oLinks = _IELinkGetCollection($oIE) For $oLink In $oLinks Local $sLinkText = _IEPropertyGet($oLink, "innerText") If StringInStr($sLinkText, $sMyString) Then _IEAction($oLink, "click") ExitLoop EndIf Next An error occurs on _IECreate. Error: 9 "C:\Program Files (x86)\AutoIt3\Include\IE.au3" (802) : ==> The requested action with this object has failed.: Return SetError($_IESTATUS_Success, $oObject.document.links.length, $oObject.document.links) Return SetError($_IESTATUS_Success, $oObject^ ERROR ->13:26:43 AutoIt3.exe ended.rc:1 Can you explain how I should read this? Thanks Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted June 27, 2018 Share Posted June 27, 2018 (edited) See how could be powerful the error "handling"? If you look in the Help file, for almost every function, you can see the Return value... Right after the Return value "sections", there is the @error sections, which tells you which error has occurred, and why. In the specific case of _IECreate, it has returned 9 as @error code, so, as you can see from the Help file: 9 ($_IEStatus_ClientDisconnected) - Client Disconnected This is the error which doesn't let you go ahead in your script You should now investigate on why the function returns that error code Best Regards. Edited June 27, 2018 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
FernanS1 Posted June 28, 2018 Author Share Posted June 28, 2018 Turns out that the reason my client was getting disconnected was because I was not "attaching" to the browser. I now fixed the code fully to navigate to the website via an index. #include <IE.au3> #include <buttonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $oIE = _IECreate("http://lc691wam.light.cos.local:7053/wamsp2/synergen/Logon?tgt=Main", 0, 1, 0, 1) Sleep(2000) $oIE = _IEAttach("Oracle") ; Enter Login Credentials $sWAMS_Username = InputBox("Username", "Enter WAMS Username?", "Enter username here", "") Send($sWAMS_Username) Send("{TAB}") $sWAMS_Password = InputBox("Password", "Enter WAMS Password?", "", "*") Send($sWAMS_Password) Send("{TAB}{ENTER}") Sleep(5000) _IEPropertyGet($oIE, "locationurl") _IELinkClickByIndex($oIE, 5) Sleep(2000) _IEPropertyGet($oIE, "locationurl") _IELinkClickByIndex($oIE, 61) Thanks for the help! 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