Using Selenium WebDriver to select JSF/PrimeFaces selectOneMenu options

I'm using JBehave with Selenium WebDriver to test my PrimeFaces (JSF2) application. Selecting an option from a SelectOne option list isn't standard though because of the HTML markup generated by the JSF component.


The facelets code to place the selectOneMenu uses the ID 'state':


This generates HTML div blocks with id's prefixed with this components id:


To select an option, I use a method which manipulates the appropriate divs - this can be used as illustrated below:


To reuse this type of utility method, I put it in a base Page Object class:



Popular posts from this blog

AspectJWeaver with JDK 7 - error - only supported at Java 5 compliance level or above

JUnit parameterized test with Spring autowiring AND transactions

Intellij tip - Joining multiple lines into one