Sign in to follow this  
Followers 0
sammy1983

click on <a href> element in webpage

9 posts in this topic

Hi,

Seeking help in Forum is amazing experience and once again, looking for someone to pull me out of this problem.

I have an internal tool in my office which has below tabs as shown in the attachment.

I am unable to navigate to "Manage Payees Tool" tab as the element has <a href = .............................................> Manage Payees Tool </a>. I know this can be accomplished using Send("{TAB 6}"), however, I think this should be the last option. Can anyone help?

post-80752-0-95357000-1392836460_thumb.j

Share this post


Link to post
Share on other sites

Have you tried "_ieclickbytext"  or "_ieclickbyindex" as describe in the help file?

 

Yes. I tried _IELinkClickByText with no success. I didnt try _IELinkClickByIndex as I need to find the index one by one entering in the code and running and checking if it's correct.

Share this post


Link to post
Share on other sites

Yes. I tried _IELinkClickByText with no success. I didnt try _IELinkClickByIndex as I need to find the index one by one entering in the code and running and checking if it's correct.

 

Ok. so I tried _IELinkClickByIndex and I am able to click on the tab. This solves. My bad that I didn't try first. However, I still want to know if there is a possibility that we can directly click on the "Text" which is between <a href = some URL> Text </a>

Share this post


Link to post
Share on other sites

Ok. so I tried _IELinkClickByIndex and I am able to click on the tab. This solves. My bad that I didn't try first. However, I still want to know if there is a possibility that we can directly click on the "Text" which is between <a href = some URL> Text </a>

That's what _IELinkClickByText() does.  It clicks based on link.outerText in .document.links

Odds are, you are not matching the text properly.  Include any white-space perhaps?

_IELinkClickByText($oIE, " Manage Payees Tool ")

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You can also check it with using the second example  from the help file:

#include <IE.au3>
$oIE = _IE_Example ("basic")
$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
For $oLink In $oLinks
MsgBox(0, "Link Info", $oLink.href)
Next

and

#include <IE.au3>
$oIE = _IECreate("http://www.autoitscript.com")
$sMyString = "wallpaper"
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
$sLinkText = _IEPropertyGet($oLink, "innerText")
If StringInStr($sLinkText, $sMyString) Then
_IEAction($oLink, "click")
ExitLoop
EndIf
Next
Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites

 

You can also check it with using the second example  from the help file:

#include <IE.au3>
$oIE = _IE_Example ("basic")
$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
For $oLink In $oLinks
MsgBox(0, "Link Info", $oLink.href)
Next

and

#include <IE.au3>
$oIE = _IECreate("http://www.autoitscript.com")
$sMyString = "wallpaper"
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
$sLinkText = _IEPropertyGet($oLink, "innerText")
If StringInStr($sLinkText, $sMyString) Then
_IEAction($oLink, "click")
ExitLoop
EndIf
Next

 

Thanks a lot DW1 and DicatoroftheUSA for showing me right path. I have one another question, though not related to this post. Can I ask?

Share this post


Link to post
Share on other sites

Its better to create a new post, think about those who may have the same question as you in the future.

 

Fair point. Will start a new post. Thanks.

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