I am trying to filter out names of books in Amazon, so after I navigated successfully and after I serached for my desired book I tried to filter out all the books that are in english on the side filter panel
When I am trying in my code to click on the 'English' languge checkbox, it does click on something but the checkbox not being checked as expected, this is the html:
and this is my code:
List<WebElement> list = driverWrapper.findElements(By.cssSelector("ul[aria-labelledby='p_n_feature_nine_browse-bin-title'] li"));
for(WebElement elem: list){
if(elem.getText().equals(LangugaeFilterOptions.ENGLISH.getValue())){
elem.click();
}
}
EDIT: This is the complete element html:
<li id="p_n_feature_nine_browse-bin/3291437011" aria-label="English" class="a-spacing-micro" xpath="1"><span class="a-list-item"> <a data-routing="" class="a-link-normal s-navigation-item" tabindex="-1" href="/s?k=lord+of+the+rings+the+two+towers&i=stripbooks-intl-ship&rh=p_n_feature_nine_browse-bin%3A3291437011&dc&crid=23TXZEAWG63AR&qid=1595601320&rnid=3291435011&sprefix=lord+of+the+rings+%2Cstripbooks-intl-ship%2C314&ref=sr_nr_p_n_feature_nine_browse-bin_1"> <div class="a-checkbox a-checkbox-fancy s-navigation-checkbox aok-float-left"><label><input type="checkbox" name="" value=""><i class="a-icon a-icon-checkbox"></i><span class="a-label a-checkbox-label"></span></label></div> <span class="a-size-base a-color-base" dir="auto">English</span> </a> </span></li>
You need to send the click on the input tag. the click is going somewhere else. Modify the CSS/Xpath to reach the input below. Hope that should help!
You can try to findElements
using xpath
instead of cssSelector
Here is the link of how you can do it -> https://stackoverflow.com/a/54746459/11278696
The problem was that this checkbox is actually a link checkbox so what is needed to do is to click on the element
driver.findElement(By.linkText("English").click();
and that's would do the trick!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.