I’m trying to get from this:
@FindBy(xpath = "//div/span/img")
public WebElement addNew;
@FindBy(xpath = "//tr[2]/td[12]")
public WebElement save;
@FindBy(xpath = "//td/div/input")
public WebElement entryIdel;
@FindBy(xpath = "//textarea")
public WebElement authorFieldel;
@FindBy(xpath = "//td[3]/div/textarea")
public WebElement titleFieldel;
that:
@FindBy(xpath = "//div/span/img")
public Button addNew;
@FindBy(xpath = "//tr[2]/td[12]")
public Button save;
@FindBy(xpath = "//td/div/input")
public InputBox entryIdel;
@FindBy(xpath = "//textarea")
public InputBox authorFieldel;
@FindBy(xpath = "//td[3]/div/textarea")
public InputBox titleFieldel;
I have previously created class for each element, but of course nothing happens. How i can create my element class so that i can use it instead of WebElement?
Here the code of InputBox at this moment:
import org.openqa.selenium.WebElement;
public class InputBox {
protected WebElement element;
public WebElement getElement() {
return element;
}
public InputBox(WebElement element) {
this.element = element;
// TODO Auto-generated constructor stub
}
public void type(String input) {
clearText();
element.sendKeys(input);
}
public void clearText() {
element.clear();
}
public boolean isEditable() {
return element.isEnabled();
}
String getText() {
return element.getText();
}
String getValue() {
return element.getValue();
}
}
Create a new implementation of FieldDecorator.
When you use the PageFactory you are probably calling
This would become
Your FieldDecorator could behave similarly to the DefaultFieldDecorator except wrap the proxy in your custom type.
See the classes here [source]