- How to define an element of type dropdown or tag as select: We can define a element of type dropdown using the statement as shown below:
Select selectElement = new Select(driver.findElement(By.id("SelectApp")));
- Example of Select tag in html page: Below example shows how the values are defined in a select dropdown.
<select id="SelectApp">
<option value="Facebook">FB</option>
<option value="TasteBook">TB</option>
<option value="ClassBook">CB</option>
<option value="HomeBook">HB</option>
<option value="TestBook">TTB</option>
</select>
- SelectByValue would select the option from the dropdown for option: <option value="Facebook">FB</option> if provided. selectByValue: Selects value based on argument value for the tag.
selectElement.selectByValue("Facebook");
- selectByVisibleText: Select value based on the text of the tag
selectElement.selectByVisibleText("FB");
- selectByIndex: select the fifth dropdown using selectByIndex
selectByIndex.selectByIndex(4);
ReplyDeleteAmazing, thanks a lot my friend, I was also siting like a your banner image when I was thrown into Selenium.
When I started learning then I understood it has got really cool stuff.
I can vouch webdriver has proved the best feature in Selenium framework.
thanks a lot for taking a time to share a wonderful article.
Selenium Training in Velachery