Jump to content

click on <a href> element in webpage


 Share

Recommended Posts

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

Link to comment
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.

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

Link to comment
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 ")
Link to comment
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
Edited by DicatoroftheUSA
Link to comment
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?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...