0

I'm currently looking for a way to click on a button on a web page to automate an export.

I've already succeeded with logging in to the web page and clicking on the login button to redirect the page, but then I could not click on the next button i'm looking for.

My code :

For Each ele In IE.document.getElementsByTagName("ul")
 If ele.document.getElementsByTagName("a").getAttribute("aria-labelledby") = "Exporter vers CSV" Then ele.Click
Next

Website source:

<ul class="dropdown-menu pull-left">
   <!-- ngRepeat: item in secondaryItems track by item.dataAid --><li ng-repeat="item in secondaryItems track by item.dataAid" class="">
     <a role="button" ng-show="item.visible" aria-labelledby="Exporter vers CSV" data-aid="tool-bar-inner-dd-btn-export" type="submit" ng-disabled="!item.enabled" ng-class="{plToolbarItemDisabled:!item.enabled, disabled:!item.enabled}" class="grid-export-item-btn" ng-click="item.callback(item, $event)" pl-toolbar-button-in-dropdown="" item="item">
underscore_d
  • 6,309
  • 3
  • 38
  • 64
f1rstsurf
  • 637
  • 1
  • 6
  • 22
  • I once faced a similar problem. In the end I just ended up checking whether or not I was logged into the site by the return url. If not logged in I prompted an error message telling the user to log in and try again. – Luuklag Dec 13 '17 at 11:41

2 Answers2

2

I cannot test it without knowing your URL, but this maywork:

For Each ele In IE.document.getElementsByTagName("ul")
    For Each ele2 In ele.getElementsByTagName("a")
        If InStr(ele2.InnerHtml, "aria-labelledby=""Exporter vers CSV""") Then ele2.Click
    Next ele2
Next ele
MarcinSzaleniec
  • 2,246
  • 1
  • 7
  • 22
1

Give this a go. When you are upon instr() function then simply the below method should get you there.

For Each ele In IE.document.getElementsByTagName("a")
    If InStr(ele.getAttribute("aria-labelledby"), "Exporter vers CSV") > 0 Then ele.Click: Exit For
Next ele
SIM
  • 21,997
  • 5
  • 37
  • 109