I've several page elements / records having xpath / id's like this
//*[@id='xyz-model-car-card-0']/car
//*[@id='xyz-model-car-card-1']/car
//*[@id='xyz-model-car-card-2']/car
and i am looking to add these webelements using List so that i can take any action on them.
List<WebElement> item = Arrays.asList();
// incase i want to navigate to 5 cards..
for(int i=0;i<5;i++) {
item.add(By.id('xyz-model-car-card-'+i));
}
but, i am unable to add it.. giving below error..
*add (org.openqa.selenium.WebElement)
in List cannot be applied to (org.openqa.selenium.By)*
Whats the best way to deal with such webelements name if we want to load them in one go.enter code here
Pl. share some example.. Thanks in advance!