Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to iterate list in java selenium

public Boolean selectByText( String text ) {
    WebElement dropDown = driver.findElement( By.xpath( ".//dropdown/path" ) );
    dropDown.click();
    List<WebElement> allOptions = dropDown.findElements(By.xpath(".//option"));
    for ( WebElement we: allOptions) { 
        dropDown.sendKeys( Keys.DOWN ); //simulate visual movement
        sleep(250);       
        if ( we.getText().contains( text ) ) select.selectByVisibleText("Value1");
    }
}
Source by sqa.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #iterate #list #java #selenium
ADD COMMENT
Topic
Name
6+8 =