1

I am trying use selenium VBA to download file. However, it cannot work by using FindElementsByXPath(). Below codes were tried, but failed:

driver.FindElementByLinkText(" Download all").Click
driver.FindElementsByXPath ("//span[contains(text(),'Download all')]")
driver.FindElementsByXPath("//span[@class='mat-button-wrapper']//span[contains(text(),'Download all')]").Click
driver.FindElementsByXPath("//button[@mat-raised-button='mat-focus-indicator mat-raised-button mat-button-base mat-primary']").Click
driver.FindElementsByXPath("//button[@class='mat-focus-indicator mat-raised-button mat-button-base mat-primary' and text()='Download all']").Click

Snapshot of the HTML:

enter image description here

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
AndyChu
  • 51
  • 1
  • 2
  • 8
  • Error messages for each attempt? Website public? Please insert html using snippet tool via [edit], not as image. – QHarr Aug 03 '22 at 03:47

1 Answers1

1

To click on the element Download all you can use either of the following locator strategies:

  • Using FindElementByCss:

    driver.FindElementByCss("button.mat-focus-indicator.mat-raised-button.mat-button-base.mat-primary span.mat-button-wrapper").Click
    
  • Using FindElementByXPath:

    driver.FindElementByXPath("//button[@class='mat-focus-indicator mat-raised-button mat-button-base mat-primary']//span[@class='mat-button-wrapper' and text()='Download all']").Click
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352