WebDriver - Automating Dropdowns Using Select Class

WebDriver supports Automating Dropdown and List controls using a special "Select" class instead of the WebElement class.
Let's create a test for a Dropdown control. This test will perform some basic checks and then call various methods to select options in dropdown.
Sample Code:
@Test
public void testDropdown() {
//Get the Dropdown as a Select using its name attribute
Select make = new Select(driver.findElement(By.name("make")));
//Verify Dropdown does not support multiple selection
assertFalse(make.isMultiple());
//Verify Dropdown has four options for selection
assertEquals(4, make.getOptions().size());
//With Select class we can select an option in Dropdown using visible Text
make.selectByVisibleText("Admin");
assertEquals("Admin", make.getFirstSelectedOption().getText());
//or we can select an option in Dropdown using value attribute
make.selectByValue("Manager");
assertEquals("Manager", make.getFirstSelectedOption().getText());
//or we can select an option in Dropdown using index
 make.selectByIndex(0);
assertEquals("Contributor", make.getFirstSelectedOption().getText());
 }

31 comments:

  1. Nice post!Thanks for sharing this information.Post more articles like this...
    We provide Selenium Online Training around the world in student's flexible time with affordable prices only. This is the right place for the persons who are looking to survive successfully in IT Market. Our faculty will help you to build your resumes and make your way easy to get a job.
    Selenium Online Training

    ReplyDelete
  2. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete
  3. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete
  4. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium.
    Selenium

    ReplyDelete
  5. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium.

    Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium.

    ReplyDelete
  6. Very informative blog and article thank you for sharing with us , keep posting learn more about selenium training , selenium online training

    ReplyDelete
  7. very informative and useful article thank you for sharing with us , keep posting learn more aboutFREE SELENIUM TRAINING DEMO VIDEOS selenium training,selenium online training

    ReplyDelete
  8. This is very informative blog and useful article thank you for sharing with us keep posting more details aboutselenium training,selenium online training

    ReplyDelete
  9. Appium Training in chennai
    We provides Best Appium Training in Chennai with real time project assistance by our leading Appium mobile App Automation testing architect
    For Free Live Demo @ Call to 8122241286.
    Appium ,Selenium,Mobile Automation Testiing using Android and IOS
    www.thecreatingexperts.com 
    Appium training in chennai

    ReplyDelete
  10. Hey friends, it was a great experience to learn from selenium.
    Talk to eight one two two two four one two eight six
    www.thecreatingexperts.com
    selenium training in chennai

    ReplyDelete
  11. Join them for the best selenium training in Chennai and placements.
    Call them at 8122241286.
    www.thecreatingexperts.com
    selenium training in chennai

    ReplyDelete
  12. Advanced Selenium Framework Training in Chennai by Vishwa

    Hi, Reach Mr.Vishwa for Best Selenium and Coded UI Training in Chennai with real time project assistance. This people will teach everything from the basics up to advanced level scenarios from frameworks.

    I learned from Mr.Vishwa and Raj they are very good automation people for Selenium Frameworks. After joined with them I learned many things and now I am writing automation scripts in own project. Vishwa 9003085882
    selenium training in chennai

    ReplyDelete
  13. An official WebDriver specification means that browser vendors will be able to create and maintain browser specific implementations of WebDriver. Microsoft has already begun using the new spec even though it isn't official and built an Internet Explorer specific implementation of WebDriver that you can use in IE 11 and newer. Blackberry and Safari are following suit. What this means to you, the user of the WebDriver framework, is that you can now rest a little easier. Browser updates will be more likely to continue working with the version of WebDriver you're using, and if they do break something will likely come with a WebDriver update.

    For Selenium, this means they are taking another step toward becoming the default browser level testing framework.

    Selenium Training

    ReplyDelete
  14. Nice article
    http://thecreatingexperts.com/selenium-training-in-chennai/

    ReplyDelete
  15. Thanks for sharing great information in your blog.

    Selenium training institute which provides Real Time Hands on Training…THE CREATING EXPERTS

    http://thecreatingexperts.com/selenium-training-in-chennai/


    contact-8122241286

    ReplyDelete
  16. Thanks for sharing this blog.Creating Experts provides Best training in selenium

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact 8122241286

    ReplyDelete
  17. The Creating Experts is the leading trainer in selenium so, if you are looking for one here is the link

    http://thecreatingexperts.com/selenium-in-chennai/

    contact +91-08122241286

    ReplyDelete
  18. THE CREATING EXPERTS is one of the leading training provider in SELENIUM they provide hands on training with real time scenario

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact +91-08122241286

    ReplyDelete
  19. THE CREATING EXPERTS is one of the leading training provider in SELENIUM they provide hands on training with real time scenario

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact +91-08122241286

    ReplyDelete
  20. The Creating Experts provides training in SELENIUM

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact +91-08122241286

    ReplyDelete
  21. The Creating Experts provides training in SELENIUM

    They provide hands on training with real time scenarios

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact +91-08122241286

    ReplyDelete
  22. nice blog...Selenium training is offered by THE CREATING EXPERTS in Chennai

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact 8122241286

    ReplyDelete
  23. SELENIUM training in Chennai by THE CREATING EXPERTS ,they provide you hands on training with real time scenarios

    http://thecreatingexperts.com/selenium-training-in-chennai/

    Contact 8122241286

    ReplyDelete
  24. SELENIUM training in Chennai

    http://thecreatingexperts.com/selenium-training-in-chennai/

    SELENIUM training in Chennai by THE CREATING EXPERTS ,

    They provide you hands on training with real time scenarios

    contact 8122241286

    ReplyDelete
  25. SELENIUM training is provided by THE CREATING EXPERTS in CHENNAI

    They provide hands on training with real time scenarios and if you are looking for one take a look at the link

    http://thecreatingexperts.com/selenium-training-in-chennai/

    Contact 8122241286 for more info

    ReplyDelete
  26. Very Nice...Contains A to Z concepts...Thanks a lot.. and looking for the best selenium training in Chennai with certification from us. we have experienced selenium experts offer selenium course training with industry exposure. Check Here https://goo.gl/VRNEXv

    ReplyDelete
  27. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging
    aws training in chennai
    selenium training in chennai

    ReplyDelete
  28. At Coepd - (Center of Excellence for Professional Development) Manual & Selenium testing training program is designed to give participants the skills & knowledge to gain a competitive advantage in starting/enhancing a career in software testing. We provide the attendee's software testing service which is required to ensure that tested applications meet all application requirements. Participants receive up-to-date training in multiple areas in Software Testing and a thorough understanding of real-world projects.

    http://www.coepd.com/TestingTraining.aspx

    ReplyDelete
  29. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.
    The Best Selenium Training in Chennai Chennai | Selenium Training institutes in Chennai

    ReplyDelete
  30. The most popular destination for Hadoop Training in

    Noida
    in NOIDA is CIITNOIDA in Sector-2

    You can Master the various components of Hadoop ecosystem like Hadoop, MapReduce Architecture, Pig, Hive, HBase, Sqoop, Flume by their Senior Experts

    from Industry with good Industrial experience of handling big projects.

    You can even Get hands-on practice with live projects and ORACLE certification at CIITNOIDA.

    This Big Data Hadoop Training in Noida is best

    suited for CS & IT Engineering Students, professionals looking to gain expertise in Big Data and work for Fortune 500 Software Companies.

    Hadoop Training in Noida
    Big Data Hadoop Training in Noida

    ReplyDelete