use of com.seleniumtests.uipage.htmlelements.Element in project seleniumRobot by bhecquet.
the class PageObject method assertForValue.
@GenericStep
public <T extends PageObject> T assertForValue(String fieldName, String value) {
Element element = getElement(fieldName);
if (element instanceof HtmlElement) {
Assert.assertTrue(((HtmlElement) element).isElementPresent(0), String.format(ERROR_ELEMENT_NOT_PRESENT, fieldName));
Assert.assertTrue(((HtmlElement) element).getText().equals(value) || ((HtmlElement) element).getValue().equals(value), String.format("Value of element %s is not %s", fieldName, value));
} else {
throw new ScenarioException(String.format(ELEMENT_S_IS_NOT_AN_HTML_ELEMENT_SUBCLASS, fieldName));
}
return (T) this;
}
use of com.seleniumtests.uipage.htmlelements.Element in project seleniumRobot by bhecquet.
the class PageObject method sendKeysToField.
@GenericStep
public <T extends PageObject> T sendKeysToField(String fieldName, String value) {
Element element = getElement(fieldName);
element.sendKeys(value);
return (T) this;
}
use of com.seleniumtests.uipage.htmlelements.Element in project seleniumRobot by bhecquet.
the class PageObject method assertForEnabled.
@GenericStep
public <T extends PageObject> T assertForEnabled(String fieldName) {
Element element = getElement(fieldName);
if (element instanceof HtmlElement) {
Assert.assertTrue(((HtmlElement) element).isElementPresent(0), String.format(ERROR_ELEMENT_NOT_PRESENT, fieldName));
Assert.assertTrue(((HtmlElement) element).isEnabled(), String.format("Element %s is disabled", fieldName));
} else {
throw new ScenarioException(String.format(ELEMENT_S_IS_NOT_AN_HTML_ELEMENT_SUBCLASS, fieldName));
}
return (T) this;
}
use of com.seleniumtests.uipage.htmlelements.Element in project seleniumRobot by bhecquet.
the class PageObject method getElement.
/**
* Returns an Element object based on field name
* @return
*/
private Element getElement(String fieldName) {
try {
Field field = getClass().getDeclaredField(fieldName);
field.setAccessible(true);
return (Element) field.get(this);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
throw new ScenarioException(String.format("Field %s does not exist in class %s", fieldName, getClass().getSimpleName()));
}
}
use of com.seleniumtests.uipage.htmlelements.Element in project seleniumRobot by bhecquet.
the class PageObject method assertForDisabled.
@GenericStep
public <T extends PageObject> T assertForDisabled(String fieldName) {
Element element = getElement(fieldName);
if (element instanceof HtmlElement) {
Assert.assertTrue(((HtmlElement) element).isElementPresent(0), String.format(ERROR_ELEMENT_NOT_PRESENT, fieldName));
Assert.assertFalse(((HtmlElement) element).isEnabled(), String.format("Element %s is enabled", fieldName));
} else {
throw new ScenarioException(String.format(ELEMENT_S_IS_NOT_AN_HTML_ELEMENT_SUBCLASS, fieldName));
}
return (T) this;
}
Aggregations