Jump to content
MonicaLu

How to click the href in HTML5 web page

Recommended Posts

I just started to use AutoIt.
Could anyone help me how to click the link below? Thanks a lot.
 

<li class="with-children closed" data-bind="template: template, css: {'disabled': isDisabled, 'with-children closed': hasChildren, 'without-children': !hasChildren(), 'current': isCurrent, 'open': isExpanded, 'closed': !isExpanded(), 'inactive': isInactive, 'ancestor': isAncestor}, attr: {'data-hj-test-id': testId}"><!-- ko ifnot: hasChildren --><!-- /ko -->
<!-- ko if: hasChildren -->
<a href="#" data-bind="click: click">
    <i data-bind="css: css"></i>
    <!-- ko if: observableText() -->
    <span data-bind="text: observableText">Translations</span>
    <!-- /ko -->
    <!-- ko if: showDropDownCaret -->
    <i class="fa fa-caret-down icon-root-with-children"></i>
    <!-- /ko -->
</a>
<ul class="dropdown-content stacked stacked-tertiary">
    <!-- ko if: !$data.parent && $data.hasChildrenWithChildren() --><!-- /ko -->
    
    <!-- ko if: isExpanded --><!-- /ko -->
</ul>
<!-- /ko --></li>

I tried the following two ways but all failed.

_IELinkClickByText($oIE, "Translations")

or 

Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    Local $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, "Translations") Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

 

Share this post


Link to post
Share on other sites

I add Sleep(3000) before upper code, then the _IELinkGetCollection() way works.
I am curious why _IELinkClickByText() doesn't work.

Share this post


Link to post
Share on other sites

@MonicaLu
Could you share the link of the webpage? :)


Click here to see my signature:

Spoiler

Thoughts:

  • 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
2 hours ago, FrancescoDiMuro said:

@MonicaLu
Could you share the link of the webpage? :)

Hi FrancescoDiMuro
Sorry I can not share the link of the webpage because it is an internal webpage which can only be accessed in our domain.
I have got it work with the following code. Thanks anyway.

Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    Local $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, "Translations") Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

 

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

×
×
  • Create New...