Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to select values from dropdown in Selenium

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 489
    Comment on it

    Value can be selected from the drop down, using the "Select" class:

    1. Select sel = new Select(driver.findElement(By.xpath("xpath_of_dropdown")));

    2. sel.selectByIndex(index_of_value_to_select);

    OR

    1. Select sel = new Select(driver.findElement(By.xpath("xpath_of_dropdown")));

    2. sel.selectByValue(value_to_be_selected);

    OR

    1. Select sel = new Select(driver.findElement(By.xpath("xpath_of_dropdown")));

    2. sel.selectByVisibleText(name_of_value);

    Eg: We have to select "March" from month dropdown

    1. sel.selectByIndex(3); // because march is on third index.

    1. sel.selectByValue(23); // Value associated with march is 23.

    1. sel.selectByVisibleText("March");

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: