The list represents an ordered list of objects, which means that you can access the list items in a specific order and index. You can also add the same item more than once to the list. The list allows null elements, and you can have many null objects in the list
You will get the whole result in a specific order one at a time. It also allows you to add duplicates. Our result may have duplicates, which are mainly necessary for automation, but if your requirements are different and you do not need duplicates, then you can use a different type of collection. If you use set, then it will not allow duplication and does not order the representation of the object.
List, , findElements()
findElement()
, , 1 ( ). List, , .
List : -
List<WebElement> allOptions = dropDown.findElements(By."OUR Locator");
for ( WebElement we: allOptions) {
dropDown.sendKeys( Keys.DOWN );
sleep(250);
if ( we.getText().contains( text ) ) select.selectByVisibleText("Value1");
}
: -
https://sqa.stackexchange.com/questions/8029/how-to-iterate-a-list-of-webelements-and-print-the-values-one-by-one-to-perform
, , : -
http://java67.blogspot.in/2013/01/difference-between-set-list-and-map-in-java.html
, add(). Collection. :
List listA = new ArrayList();
listA.add("element 1");
listA.add("element 2");
listA.add("element 3");
, : -
String element0 = listA.get(0);
String element1 = listA.get(1);
String element3 = listA.get(2);
System.out.println(element0+" "+element1+" "+element3
);
, :)