如何单击具有类似类名称和属性的IE按钮



我目前卡住了尝试单击私人网站上的按钮。我要单击的按钮具有相同的属性,我无法区分我需要单击的按钮。这是我要单击的三个按钮。如您所见,它们是相似的,除了按钮上的文本。如何选择特定按钮并单击它?

<button ng-repeat="punch in $ctrl.nextPunches" ng-disabled="punch.sendingPunch || $ctrl.sendingPunch" type="button" class="btn btn-default ng-binding ng-scope" ng-click="$ctrl.addPunch(punch)" style="">
                        <!-- ngIf: punch.sendingPunch -->
                        Check In
                    </button>

====================================================================================

<button ng-repeat="punch in $ctrl.nextPunches" ng-disabled="punch.sendingPunch || $ctrl.sendingPunch" type="button" class="btn btn-default ng-binding ng-scope" ng-click="$ctrl.addPunch(punch)">
                        <!-- ngIf: punch.sendingPunch -->
                        Start Meal
                    </button>

====================================================================================

<button ng-repeat="punch in $ctrl.nextPunches" ng-disabled="punch.sendingPunch || $ctrl.sendingPunch" type="button" class="btn btn-default ng-binding ng-scope" ng-click="$ctrl.addPunch(punch)">
                        <!-- ngIf: punch.sendingPunch -->
                        Check Out
                    </button>

我尝试使用以下方式:

Set HTMLButtons = HTMLDoc.getElementsByTagName("button")
    For Each HTMLbutton In HTMLButtons
       Debug.Print HTMLbutton.getAttribute("ng-click"), HTMLbutton.getAttribute("type"), HTMLbutton.getAttribute("ng-repeat"), HTMLbutton.getAttribute("ng-disabled")
    Next HTMLbutton
    HTMLButtons(2).Click

但是,在即时窗口上显示的按钮无用,当我使用.click命令时,它不会单击任何按钮。这些按钮位于网页上的UI元素下方。我不确定这是否有帮助,但是如果需要,我绝对可以提供更多的网页代码。

谢谢!

您可以使用document.getElementsByClassName方法或document.getElementsByTagname方法获取按钮(它将返回一个数组(,然后,循环循环浏览此数组并基于>区分它们innertext 属性。更多详细信息,您可以检查本文。

此外,您还可以添加一些自定义属性并设置不同的值,然后使用它来区分它们。

最新更新