Jump to content
FernanS1

Opening IE link - URL issues

Recommended Posts

FernanS1
Posted (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:

image.png.06d45785cd53839bb329fa79d33a3f48.png

The error I am getting is shown below:

image.png.ebf8ccaba368bd22465d82e55ce7f0ae.png

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 by FernanS1

Share this post


Link to post
Share on other sites
FrancescoDiMuro

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

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

ALWAYS GOOD TO READ:

Share this post


Link to post
Share on other sites
FernanS1
Posted (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 by FernanS1

Share this post


Link to post
Share on other sites
FrancescoDiMuro
Posted (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 by FrancescoDiMuro

Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

ALWAYS GOOD TO READ:

Share this post


Link to post
Share on other sites
FernanS1

@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 :)

Share this post


Link to post
Share on other sites
FrancescoDiMuro
Posted (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 by FrancescoDiMuro

Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

ALWAYS GOOD TO READ:

Share this post


Link to post
Share on other sites
FernanS1

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!

 

Share this post


Link to post
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

×