public abstract class Element {protected final WebDriver driver;//@FindBy won't work here because this is in the base class// and needs unique valuesprotected WebElement e;public Element(WebDriver driver) {this.driver = driver;}public String getAttribute(String name) {return e.getAttribute(name);}....}
public class LabelElement extends Element { ... }
public abstract class Element {
protected WebElement element;
public Element(WebElement element) {
this.element = element;
}
public String getAttribute(String name) {
return element.getAttribute(name);
}
public void doSomethingCommon() {
.......
}
....
}
> --
> You received this message because you are subscribed to the Google Groups
> "webdriver" group.
> To post to this group, send email to webd...@googlegroups.com.
> To unsubscribe from this group, send email to
> webdriver+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/webdriver?hl=en.
>
//Title Elements - shared with all lesson types.<label><span class="">Lesson Title —</span><span class="sub-label">(1024 characters max)</span></label><input gtbfieldid="4" name="view:courseTitle" value="A1 - Teacher's Resource Lesson" type="text">//Description Elements - shared with all lesson yypes<label><span class="">Lesson Description —</span><span class="sub-label">(2048 characters max)</span></label><textarea rows="10" cols="60" name="view:courseDescription">test</textarea>//URL for Online Lesson - unique to online lesson type<label><span class="">URL where lesson is hosted —</span><span class="sub-label">(full URL - 1024 characters max)</span></label><input gtbfieldid="5" name="view:courseUrl" value="http://www.google.com" type="text">
You can pass in a custom field decorator to
PageFactory.initElements(FieldDecorator decorator, Object page)
org.openqa.selenium.support.pagefactory.FieldDecorator has a concise,
well defined interface, and the default implementation which just
fills in WebElements:
org.openqa.selenium.support.pagefactory.DefaultFieldDecorator is
surprisingly simple :)