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

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 779
    Comment on it

    Method Name: selectByVisibleText
    Syntax: select.selectByVisibleText(Text);
    Purpose: To Select the options based on text, matching with the argument given by user., it will try to match the VisibleText which will display in dropdown.

    The below is the sample HTML code Example:
    HTML Code:

    <title>Select Example by Index value</title>
    <select name="Days"><option value="0" selected=""> Please select</option>
    <option value="1">Mon</option>
    <option value="2">Tue</option>
    <option value="3">Wed</option>
    <option value="4">Thu</option>
    <option value="5">Fri</option>
    <option value="6">Sat</option>
    <option value="7">Sun</option>
    </select>
    

    Web-driver code for Selecting a Value using selectByVisibleText(Text);

    public class selectByVisibleTextExample {
    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("Days"));
    Select se=new Select(element);
    se.selectByVisibleText("Wed");
    }
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
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: