Search in sources :

Example 1 with HtmlUnitWebElement

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();
}
Also used : HiddenHtmlElementState(com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState) HtmlUnitWebElement(org.openqa.selenium.htmlunit.HtmlUnitWebElement) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 2 with HtmlUnitWebElement

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;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) HiddenBrowserDriver(com.axway.ats.uiengine.HiddenBrowserDriver) HtmlUnitWebElement(org.openqa.selenium.htmlunit.HtmlUnitWebElement) ElementNotFoundException(com.axway.ats.uiengine.exceptions.ElementNotFoundException) WebElement(org.openqa.selenium.WebElement) HtmlUnitWebElement(org.openqa.selenium.htmlunit.HtmlUnitWebElement)

Example 3 with HtmlUnitWebElement

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();
}
Also used : HtmlUnitWebElement(org.openqa.selenium.htmlunit.HtmlUnitWebElement) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 4 with HtmlUnitWebElement

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() + ")");
}
Also used : HiddenHtmlElementState(com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState) HtmlUnitWebElement(org.openqa.selenium.htmlunit.HtmlUnitWebElement) WebElement(org.openqa.selenium.WebElement) HtmlUnitWebElement(org.openqa.selenium.htmlunit.HtmlUnitWebElement) SeleniumOperationException(com.axway.ats.uiengine.exceptions.SeleniumOperationException) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 5 with HtmlUnitWebElement

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();
}
Also used : HiddenHtmlElementState(com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState) HtmlUnitWebElement(org.openqa.selenium.htmlunit.HtmlUnitWebElement) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

HtmlUnitWebElement (org.openqa.selenium.htmlunit.HtmlUnitWebElement)14 PublicAtsApi (com.axway.ats.common.PublicAtsApi)13 HiddenHtmlElementState (com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState)12 WebElement (org.openqa.selenium.WebElement)7 SeleniumOperationException (com.axway.ats.uiengine.exceptions.SeleniumOperationException)6 ArrayList (java.util.ArrayList)2 HiddenBrowserDriver (com.axway.ats.uiengine.HiddenBrowserDriver)1 ElementNotFoundException (com.axway.ats.uiengine.exceptions.ElementNotFoundException)1 WebDriver (org.openqa.selenium.WebDriver)1