2

I can't click on an element in the screen, it's not a button but works like one. I have successfully located it through the web inspector (I think) but I can't figure out the reason of why isn't working... Previously in my code I used the same code for clicking in a "Log in" button and it worked perfectly. Here it is the code:

    Set objCollection = IE.document.getelementsbytagname("div")
    For Each elem In objCollection
        If IsObject(IE.document.getElementsByClassName("btn-group")) Then 'Scratchpad button clicking
            If IsObject(IE.document.getElementsByClassName("pull-left fang-button fang-button-subtle no-margin ng-binding")) Then
                Debug.Print "found it"
                elem.Click
                Exit For
            End If
        End If
    Next elem

I'm trying to click in the element "Scratchpad" at the top of the page, as the image shows. Thanks in advance!

HTML:

<div class="btn-group" role="group" style="border:1px solid #ccc"> <a ng-class="{'active': !CrossSegmentConfig.showScratchPad &amp;&amp; !CrossSegmentConfig.showGraph}" class="pull-left fang-button fang-button-subtle no-margin ng-binding active" ng-click="CrossSegmentConfig.showScratchPad=false; CrossSegmentConfig.showGraph=false;" style=""> <i class="fa fa-align-left"></i> Parameters </a> <a ng-class="{'active': CrossSegmentConfig.showScratchPad}" class="pull-left fang-button fang-button-subtle no-margin ng-binding" ng-click="CrossSegmentConfig.toggleScratchPad()" style=""> <i class="fa fa fa-columns"></i> Scratchpad </a> <a ng-class="{'active': CrossSegmentConfig.showGraph}" class="pull-left fang-button fang-button-subtle no-margin ng-binding" ng-click="CrossSegmentConfig.toggleGraph()"> <i class="fa fa-line-chart"></i> Plot </a> </div>
2
  • Try iterating this collection ie.Document.getElementsByClassName("btn-group").getElementsByTagName("a") and look for InnerText or InnerHTML being equal to ScratchPad Commented Apr 2, 2019 at 20:10
  • @RyanWildry thanks for your repy! Tried to do so on the objCollection line but this error pops up: "object does not accept this property or method" Commented Apr 2, 2019 at 20:52

1 Answer 1

1

It's an Angular JS directive. Try either of the following 2

ie.document.querySelector("[ng-click*=toggleScratchPad]").click

ie.document.parentWindow.execScript "document.querySelector('[ng-click*=toggleScratchPad]').click();"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.