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:
CodePudding user response:
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