Skip to content

Commit

Permalink
Refactoring some old multi-select code
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Jun 1, 2015
1 parent bf01941 commit ebb8471
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public void selectMultipleItems(final String... selectedLabels) {
Select select = new Select(dropdown);
for (String selectedLabel : selectedLabels) {
select.selectByVisibleText(selectedLabel);
// String optionPath = String.format("//option[.='%s']", selectedLabel);
// WebElement option = dropdown.findElement(By.xpath(optionPath));
// option.click();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;

import java.util.HashSet;
import java.util.List;
Expand All @@ -18,8 +19,10 @@ public MultipleSelect(final WebElement dropdownField) {
}

public Set<String> getSelectedOptionLabels() {
Set<String> selectedOptions = new HashSet<String>();
List<WebElement> options = dropdownField.findElements(By.tagName("option"));

List<WebElement> options = new Select(dropdownField).getAllSelectedOptions();

Set<String> selectedOptions = new HashSet<>();
for (WebElement option : options) {
if (option.isSelected()) {
selectedOptions.add(option.getText());
Expand Down

0 comments on commit ebb8471

Please sign in to comment.