how to iterate list in java selenium

Solutions on MaxInterview for how to iterate list in java selenium by the best coders in the world

showing results for - "how to iterate list in java selenium"
Eric
14 Mar 2020
1Iterator<WebElement> itr = allLinks.iterator();
2while(itr.hasNext()) {
3    System.out.println(itr.next().getText());
4}
Lucia
27 Apr 2017
1public Boolean selectByText( String text ) {
2    WebElement dropDown = driver.findElement( By.xpath( ".//dropdown/path" ) );
3    dropDown.click();
4    List<WebElement> allOptions = dropDown.findElements(By.xpath(".//option"));
5    for ( WebElement we: allOptions) { 
6        dropDown.sendKeys( Keys.DOWN ); //simulate visual movement
7        sleep(250);       
8        if ( we.getText().contains( text ) ) select.selectByVisibleText("Value1");
9    }
10}