Catalin Caila :
Step 1. Go to:https://www.amazon.com/international-sales-offers/b/?ie=UTF8&node=15529609011&ref_=nav_navm_intl_deal_btn
Step 2. Try to locate the checkbox button Books with Inspector
Step 3. Click on checkbox button to be selected
Step 4. enter image description here
I try to iterate and to find the unique identifier "Books". If you know another way to do click without to iterate is fine. I used this lines of code:
List<WebElement> elements = new ArrayList<WebElement>(obj.findElements(By.cssSelector("span.a-label.a-checkbox-label")));
for (WebElement element : elements) {
if (element.getText() == "Books"){
System.out.println("");
element.click();
}
else
System.out.println("Condtition from if is not true");
}
frianH :
You can achieve without iterate, please locate the element by xpath with this value: //label[contains(., 'Books')]//input
.
WebElement element = driver.findElement(By.xpath("//label[contains(., 'Books')]//input"));
element.click();
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=352982&siteId=1