vendredi 23 décembre 2016

Selecting check box value using java in selenium

[Hello All i need to select a checkbox value from the given attachment.

Problem is it is not desinged such a way, i can choose id of the particular value.

I wanted to find the List of elements under Material block and select the value cotton.

I m very new to selenium and i tried to display the elements first using the below code

List materialList = driver.findElements(By.id("ref_3248233031")); boolean materiaListIsdisplayed = ((WebElement) materialList).isDisplayed(); System.out.println("Material Block is displayed" +materiaListIsdisplayed); //System.out.println(materialList.getText()); String checkBoxEachValue = ((WebElement) materialList.get(0)).getAttribute("value"); System.out.println(checkBoxEachValue);

]1

But it keeps giving the exception as below

Exception in thread "main" java.lang.ClassCastException: java.util.ArrayList cannot be cast to org.openqa.selenium.WebElement at com.jahira.addtocart.searchBedsheets.filterBedsheets(searchBedsheets.java:57) at com.jahira.addtocart.searchBedsheets.main(searchBedsheets.java:121)

Kindly let me know what mistake is i m doing and also help to select the value form list of checkbox




Aucun commentaire:

Enregistrer un commentaire