Skip to content

Instantly share code, notes, and snippets.

@prule
Last active December 21, 2015 05:19
Show Gist options
  • Select an option

  • Save prule/6255979 to your computer and use it in GitHub Desktop.

Select an option

Save prule/6255979 to your computer and use it in GitHub Desktop.
/*
The facelets code uses the id "state"
<p:selectOneMenu id="state" value="#{myBean.state}">
...
</p:selectOneMenu>
*/
// sample invocation to select element
selectOne("myForm:state", "Disabled");
// select given option
public void selectOne(String idPrefix, String value) {
if (StringUtils.isNotBlank(value)) {
getDriver().findElement(By.id(idPrefix + "_label")).click();
getDriver().findElement(By.xpath("//div[@id='" + idPrefix + "_panel']/div/ul/li[text()='" + value + "']")).click();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment