Example: Override existing ElementHandler
Illustrates how the default behavior of a textbox element can be overwritten by defining a new ElementHandler so that only certain methods of existing overrides are overwritten. In this case, look for a div with the right text (the description in the textbox) and then look for a textbox within the parent container of the div.
Use
In all steps the textbox element is automatically replaced by the modified version.
* i should see textbox "Some label"
Java code
@Component public class UmbracoTextElementHandler extends TextElementHandler { @Override public ElementStub find( ElementDescriptor descriptor ) { ElementStub found = super.find( descriptor ); if ( found == null || !found.exists() ) { ElementStub divLabel = addParents( browser.div( descriptor.getSahiArguments() ), descriptor ); if ( divLabel.exists() ) { return browser.textbox(0).in( divLabel.parentNode() ); } } return found; } }