over 11 years ago
Value can be selected from the drop down, using the "Select" class:
copytext
Select sel = new Select(driver.findElement(By.xpath("xpath_of_dropdown")));sel.selectByIndex(index_of_value_to_select);
Select sel = new Select(driver.findElement(By.xpath("xpath_of_dropdown")));
Select sel = new Select(driver.findElement(By.xpath("xpath_of_dropdown"))); sel.selectByIndex(index_of_value_to_select);
OR
Select sel = new Select(driver.findElement(By.xpath("xpath_of_dropdown")));sel.selectByValue(value_to_be_selected);
Select sel = new Select(driver.findElement(By.xpath("xpath_of_dropdown"))); sel.selectByValue(value_to_be_selected);
Select sel = new Select(driver.findElement(By.xpath("xpath_of_dropdown")));sel.selectByVisibleText(name_of_value);
Select sel = new Select(driver.findElement(By.xpath("xpath_of_dropdown"))); sel.selectByVisibleText(name_of_value);
Eg: We have to select "March" from month dropdown
sel.selectByIndex(3); // because march is on third index.
sel.selectByValue(23); // Value associated with march is 23.
sel.selectByVisibleText("March");
Can you help out the community by solving one of the following JAVA problems?
Suggestion for scalable java based socket server?
What is the Use of Parent Child Inheritance Method?
How to Call Parametrized Method from LibraryCollect...
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Sign up using
0 Comment(s)