Skip to content
This repository has been archived by the owner on Nov 17, 2017. It is now read-only.

Commit

Permalink
Metamer: Attributes: Add support for apply select by option label
Browse files Browse the repository at this point in the history
By default is applied option value, but for some selects (e.g. icons: option labeled "star" contains full path to star.png file and tests fails using key from sources using selenium (which actually supports selects by option label)
  • Loading branch information
jjamrich committed Mar 11, 2013
1 parent 151a29f commit 5a70a02
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.webdriver;

import java.util.Iterator;
import java.util.List;

import org.apache.commons.lang.Validate;
Expand Down Expand Up @@ -201,12 +202,26 @@ private void applySelect(Tag tag, String value) {
}
}
} else {
tag.selection.selectByValue(value);
if (isSelectOptionsContainingValue(value, tag.selection.getOptions())) {
tag.selection.selectByValue(value);
} else {
tag.selection.selectByVisibleText(value);
}
return;
}
throw new IllegalArgumentException("No property with value " + value + " was found");
}

private boolean isSelectOptionsContainingValue(String value, List<WebElement> options) {
for (Iterator<WebElement> i = options.iterator(); i.hasNext();) {
if (value.equals(i.next().getAttribute("value"))) {
return true;
}
}
System.out.println(" Value '" + value + "' was not found in select's options as @value. Consider use it as option label.");
return false;
}

/**
* Retrieve current attribute value
*
Expand Down

0 comments on commit 5a70a02

Please sign in to comment.