use of org.openqa.selenium.htmlunit.HtmlUnitWebElement in project ats-framework by Axway.
the class HiddenHtmlCheckBox method check.
/**
* Check the check box
*/
@Override
@PublicAtsApi
public void check() {
new HiddenHtmlElementState(this).waitToBecomeExisting();
HtmlUnitWebElement element = HiddenHtmlElementLocator.findElement(this);
if (!element.isEnabled()) {
throw new UnsupportedOperationException("You may not check a disabled element." + toString());
}
if (!element.isSelected()) {
element.click();
}
UiEngineUtilities.sleep();
}
use of org.openqa.selenium.htmlunit.HtmlUnitWebElement in project ats-framework by Axway.
the class HiddenHtmlElementLocator method findElement.
public static HtmlUnitWebElement findElement(UiElement uiElement, String xpathSuffix, boolean verbose) {
HiddenBrowserDriver browserDriver = (HiddenBrowserDriver) uiElement.getUiDriver();
WebDriver webDriver = (WebDriver) browserDriver.getInternalObject(InternalObjectsEnum.WebDriver.name());
HtmlNavigator.getInstance().navigateToFrame(webDriver, uiElement);
String xpath = uiElement.getElementProperties().getInternalProperty(HtmlElementLocatorBuilder.PROPERTY_ELEMENT_LOCATOR);
String css = uiElement.getElementProperty("_css");
if (xpathSuffix != null) {
xpath += xpathSuffix;
}
List<WebElement> elements = null;
if (!StringUtils.isNullOrEmpty(css)) {
elements = webDriver.findElements(By.cssSelector(css));
} else {
elements = webDriver.findElements(By.xpath(xpath));
}
if (elements.size() == 0) {
throw new ElementNotFoundException(uiElement.toString() + " not found.");
} else if (elements.size() > 1) {
if (verbose) {
log.warn("More than one HTML elements were found having properties " + uiElement.toString() + ".Only the first HTML element will be used.");
}
}
HtmlUnitWebElement element = (HtmlUnitWebElement) elements.get(0);
if (verbose) {
log.info("Found element: " + element.toString());
}
return element;
}
use of org.openqa.selenium.htmlunit.HtmlUnitWebElement in project ats-framework by Axway.
the class HiddenHtmlRadioList method select.
/**
* Select radio button
*
* @param value of the button to select
*/
@PublicAtsApi
public void select(String value) {
HtmlUnitWebElement element = HiddenHtmlElementLocator.findElement(this, "[@value='" + value + "']", true);
if (!element.isEnabled()) {
throw new UnsupportedOperationException("You may not select a disabled element." + toString());
}
element.click();
UiEngineUtilities.sleep();
}
use of org.openqa.selenium.htmlunit.HtmlUnitWebElement in project ats-framework by Axway.
the class HiddenHtmlSingleSelectList method setValue.
/**
* set the single selection value
*
* @param value the value to select
*/
@Override
@PublicAtsApi
public void setValue(String value) {
new HiddenHtmlElementState(this).waitToBecomeExisting();
HtmlUnitWebElement selectElement = HiddenHtmlElementLocator.findElement(this);
List<WebElement> optionElements = selectElement.findElements(By.tagName("option"));
for (WebElement el : optionElements) {
if (el.getText().equals(value)) {
((HtmlUnitWebElement) el).click();
UiEngineUtilities.sleep();
return;
}
}
throw new SeleniumOperationException("Option with label '" + value + "' not found. (" + this.toString() + ")");
}
use of org.openqa.selenium.htmlunit.HtmlUnitWebElement in project ats-framework by Axway.
the class HiddenHtmlTextArea method setValue.
/**
* Set the Text Area value
*
* @param value
*/
@Override
@PublicAtsApi
public void setValue(String value) {
new HiddenHtmlElementState(this).waitToBecomeExisting();
HtmlUnitWebElement element = HiddenHtmlElementLocator.findElement(this);
element.clear();
element.sendKeys(value);
UiEngineUtilities.sleep();
}
Aggregations