Sign in to follow this  
Followers 0
sevesteen

Click on a changing URL link in IE

6 posts in this topic

I am an absolute beginner to Autoit, with little programming experience. I am trying to automate logging on to a Citrix application, where we have to open a link in IE, enter login info, then click links on 2 successive web pages to launch the app.

I'm fine until clicking the link on the second page. That link is the same unique icon in the same place with the same title, but the URL it points to is specific to each login attempt. The first 3 feet or so of URL is the same each time, but there is a unique token that is different for each login.

I can't find anything unique about this button in Window Info other than coordinates, How do I click on this button? I've searched Google, but it seems that the Autoit tutorials I can find skip over this lesson and go directly to more advanced topics.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Here are a few options for you.

Use _IELinkClickByText if the link text stays the same but the URL changes.

#include <IE.au3>
$oIE = _IECreate("http://www.autoitscript.com/")
_IELinkClickByText($IE, "forum")

Use _IELinkClickByIndex if the index of the link never changes and you can't use _IELinkClickByText.

#include <IE.au3>
$oIE = _IECreate("http://www.autoitscript.com/")
_IELinkClickByIndex($oIE, 17)

Use StringInStr if you only know part of the URL and you don't know what the index is going to be.

#include <IE.au3>
$oIE = _IECreate("http://www.autoitscript.com/")
;gets all the links on the page
$oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    ;looks for some text within the links URL
    If StringInStr($oLink.href, "autoitscript.com/for") Then
        _IENavigate($oIE, $oLink.href)
        ExitLoop
    EndIf
Next

Welcome to the the forum.

Edited by Herb191

Share this post


Link to post
Share on other sites

Thanks, I appriciate the help as I learn this.

I'm trying to make the first version you suggested work, modified as best I can to fit my situation.

Sanitized version of my script (specific site and logon info changed to protect my employment)

#include <IE.au3>

_IECreate("http://mysite/login.htm")

WinWaitActive("mysite - Logon - Microsoft Internet Explorer")

send("username")

sleep(250)

send("{tab}")

sleep(250)

send("password")

send("{enter}")

WinWaitActive("Citrix apps- Microsoft Internet Explorer")

_IELinkClickByText ( $IE, "Linktitle")

Works fine until the last line, I get error message

Line 30 (File "D:AutoITMyProgram.au3"):

_IELinkClickByText($IE, Linktitle")

_IELinkClickByText(^ERROR

Error: Variable Used without being declared

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Sevesteen, change the second line in your script to:

$IE = _IECreate("http://mysite/login.htm")

Edited by Tonnie

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Sevesteen, Tonnie is right you need to add "$IE =" to the second line. Also if you have the time I would highly recommend you learn how to use the _IEFormElementSetValue function (with the other IE functions). It is a lot more reliable then using the send command.

Edited by Herb191

Share this post


Link to post
Share on other sites

Adding "$IE =" did get rid of the error, but did not cause a click. This appears to be specific to the page I'm trying to automate--I was concerned that in redacting my employers info I changed something relevant. It seemed easier to make a version that logged on here, and once I got that working modify it back to the original task. The modified version worked immediately...

I think the easiest way for me to go is to open IE at a particular size and click on particular coordinates. Thanks again, and I'll probably be back.

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
Sign in to follow this  
Followers 0