Selenium Select class is used to perform actions on drop-down:
Different functions provided by Select class:
Sample Code:
WebElement dropdown = driver.findElement(By.name("dropdown"));
Select select = new Select(dropdown);
// Here we will perform the multiselect operation in the dropdown.
select.selectByVisibleText("John");
Different functions provided by Select class:
selectByVisibleText()/deselectByVisibleText()
|
selects or deselects an option by its visible text from drop down
|
selectByValue()/deselectByValue()
|
selects or deselects an option by the value displayed for "value" attribute
|
selectByIndex()/deselectByIndex()
|
selects or deselects an option by its index
|
isMultiple()
|
returns TRUE if the drop-down allows multiple selection at a time and return FALSE if not allowed
|
deselectAll()
|
deselects all selected options
|
Sample Code:
WebElement dropdown = driver.findElement(By.name("dropdown"));
Select select = new Select(dropdown);
// Here we will perform the multiselect operation in the dropdown.
select.selectByVisibleText("John");
No comments:
Post a Comment