Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Selenium Web-driver Syntax for Selecting a Value using selectByValue method

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 545
    Comment on it

    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>

    Webdriver code for Selecting a Value using selectByValue(Value);

    public class selectByValueExample {
    public static void main(String args[]) {
    WebDriver driver = new FirefoxDriver () ;
    WebElement element=driver.findElement("Months"));
    Select se=new Select(element);

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: