How to select an option from the Dropdown element in Selenium Webdriver?

Step1: Create a Web-element and assign the path of Drop-down element to the Web-element.          

 WebElement Dropdownelementtest = driver.findelement(by.-----());  

Step2: Create a Select object and assign a Web-element object to the Select object created.          

  Select Dropdownoptiontest = new Select(Dropdownelementtest);  

Step3: Select the value from the Dropdown element.
           We have three types of method available to select option from Dropdown list
            Select by Index          

 Dropdownoptiontest.selectByIndex(" ");  

           Select by value          

 Dropdownoptiontest.selectByValue(" ");  

           Select by Visible Text          

 Dropdownoptiontest.selectByVisibleText(" ");  

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s