Reputation: 595
Q. Same kind of class applied to all Download button,How to distinct them from each other? Let's say i want to click on 3rd number of download button. Find a xpath for that button.
I have tried this but it's common for all.
//div[@class='statement-download']
<div class="statement-download">
<button class="btn btn-sm btn-icon btn-outline btn-default mb-0" type="button">
<i class="mdi mdi-download m-r-5"></i>
<span>Download</span>
</button>
</div>
Upvotes: 1
Views: 49
Reputation: 2707
It's a better way you can do it by using loops if you have multiple operations
List<WebElement> statementdownload =
driver.findElements(By.xpath("//div[@class='statement-download']"));
for (int i=0;i<statementdownload.size();i++) {
statementdownload.get(i).click();
statementdownload.get(i).getText();
// You can use your condition here
}
Upvotes: 0
Reputation: 50909
You can use the date as a starting point
date = 'July 2048'
//div[.='{date}']/following-sibling::div[@class='statement-download']
Upvotes: 0
Reputation: 7563
For 3rd, try following xpath
:
(//div[@class='statement-download'])[3]
Upvotes: 0
Reputation: 13016
use the index
of the parent div
.
//div[@class='statement-card'][3]/div[@class='statement-download']
Upvotes: 1