I'm using JSF 1.2. We want to write some selenium tests (based on xpath) but xpath does not seem to have wildcard matching on element id's.
We cannot turn off prefix ids as we are running as a portlet within IBM Portal Server 6.1 and our application breaks in that environment with the prefix turned off.
Currently we are using xpaths of the form
//*[substring(@id, 54)='id_distributorName']
which will match:
<select size="1" class="firstName" name="viewns_7_8000CB1A0GUIE0IJF799CR10O2_:commonEntryForm:id_distributorName" id="viewns_7_8000CB1A0GUIE0IJF799CR10O2_:commonEntryForm:id_distributorName" >
but it strikes me that assuming JSF will always generate a viewId of the same length is dangerous.
Is there a better way to do this?
We've tried using the name
attribute for our input controls but of course JSF ignores the attribute and writes it's own name attribute whose value matches the id presumably for evant handling scripting reasons)