- 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
Just like CheckBox & Radio Buttons, DropDown & Multiple Select Operations also works together and almost the same way. To perform any action, the first task is to identify the element group. I am saying it a group, as DropDown /Multiple Select is not a single element. They always have a single name but and they contains one or more than one elements in them. I should rather say more than one option in DropDown and Multiple Select. The only difference between these two is deselecting statement & multiple selections are not allowed on DropDown . Let’s look at the different operations:
ReplyDeleteBest Selenium Training Institute in Chennai