description
Locate form elements in selenium tests by matching the text in their associated labels. A label can be associated with a form control by either setting its "for" attribute to the id of the form control or by nesting the form control within the label tag. This locator supports both methods and will support nested input, select, textarea and button tags.
example of use
For a form containing the HTML:
<label for="inputWithId">Input with ID:</label> <input id="inputWithId" />
<label>Nested Input: <input id="nestedInput" /></label>
Text can be typed into the two inputs using the following selenium commands:
| type |
labelText=Input with ID: |
input found by id |
| type |
labelText=Nested Input* |
nested input found |
notes
- Use this extension with Selenium 0.6.0.
- The text can be specified using a pattern.
- This extension will throw an exception under a few circumstances:
- If a label with matching text is not found.
- If a label with matching text is found but it has no associated form control.
- If a label with matching text is found and its for attribute points to an ID that doesn't exist.
- If a label with matching text is found and it has more than one nested form control.
- This extension has been tested in IE 6.0 and Firefox 1.0.7
download
findByLabelText_1_0
Thanks for your extention. I installed it and got it to work.
Before that, I used this code pasted in as a "dom=" selector.