Example: Simple new ElementHandler
In this example, a new tab element is defined that can be used in all of the standard steps. Also illustrates the use of the addition of the standard parent functionality in custom elements..
Use
An own element can automatically be used in the standard steps, even as parent.
* i should see tab "duplicate" 2 * i see link "somelink" in tab "tabname"
Java code
@Component public class TabElementHandler extends ElementHandler { public final String TAB = "tab"; @Override public boolean canHandle( ElementDescriptor descriptor ) { return StringUtils.equalsIgnoreCase( TAB, descriptor.getType() ); } @Override public ElementStub find( ElementDescriptor descriptor ) { ElementStub tabContainer = addParents( browser.list( "/primary-tabs/" ), descriptor ); if ( tabContainer.exists() ) { return browser.link( descriptor.getLocator() ).in( tabContainer ); } else { return tabContainer; } } @Override public void set( ElementDescriptor descriptor ) { throw new RuntimeException( "Set not implemented for tab" ); } @Override public void verify( ElementDescriptor descriptor, boolean expectedOutcome ) { throw new RuntimeException( "Verify not implemented for tab" ); } }