#Java - Code Snippets for '#Webelement' - 2 code snippet(s) found |
|
Sample 1. Select an option using the select element name and the expected option value | |
|
void select(String name, String value) {
WebElement element = By.name(name);
List<WebElement> options = element.findElements(By.tagName("option"));
for (WebElement option : options) {
if (option.getText().equals(value)) {
option.click();
return;
}
}
}
|
|
Like Feedback selenium webdriver webelement |
|
|
Sample 2. Selenium - WebDriver - Method to check if an option has already been selected | |
|
boolean isSelected(String selectName, String optionValue) {
WebElement element = By.name(name);
List<WebElement> options = element.findElements(By.tagName("option"));
for (WebElement option : options) {
if (option.getText().equals(value)) {
return option.isSelected();
}
}
return false;
}
|
|
Like Feedback selenium webdriver WebElement |
|
|