over 5 years ago
Method Name: selectByValue Syntax: select.selectByValue(Value); Purpose: To Select the options based on value, matching with the argument given by user.
The below is the sample html code Example: HTML Code:
<title>Select Example by Index value</title> <select name="Months"><option value="0" selected=""> Please select</option> <option value="1">Jan</option> <option value="2">Feb</option> <option value="3">Mar</option> <option value="4">Apr</option> <option value="5">May</option> <option value="6">Jun</option> <option value="7">Jul</option> <option value="8">Aug</option> <option value="9">Sept</option> <option value="10">Oct</option> <option value="11">Nov</option> <option value="12">Dec</option> </select>
public class selectByValueExample { public static void main(String args[]) { WebDriver driver = new FirefoxDriver () ; driver.manage().window().maximize(); driver.get("file:///C:/Users/Piyush/Desktop/Months.html"); WebElement element=driver.findElement(By.name("Months")); Select se=new Select(element); se.selectByValue("Aug"); } }
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)