Search in sources :

Example 6 with HtmlUnitWebElement

use of org.openqa.selenium.htmlunit.HtmlUnitWebElement in project ats-framework by Axway.

the class HiddenHtmlTextBox method appendValue.

/**
     * Append text to the current content of a Text Box
     * 
     * @param value
     */
@PublicAtsApi
public void appendValue(String value) {
    new HiddenHtmlElementState(this).waitToBecomeExisting();
    HtmlUnitWebElement element = HiddenHtmlElementLocator.findElement(this);
    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)

Example 7 with HtmlUnitWebElement

use of org.openqa.selenium.htmlunit.HtmlUnitWebElement in project ats-framework by Axway.

the class HiddenHtmlMultiSelectList method setValue.

/**
     * select a value
     *
     * @param value the value to select
     */
@Override
@PublicAtsApi
public void setValue(String value) {
    new HiddenHtmlElementState(this).waitToBecomeExisting();
    HtmlUnitWebElement selectElement = HiddenHtmlElementLocator.findElement(this);
    if (selectElement.getAttribute("multiple") == null) {
        throw new SeleniumOperationException("Not a multi-select. You may only add a selection to a select that supports multiple selections. (" + this.toString() + ")");
    }
    List<WebElement> optionElements = selectElement.findElements(By.tagName("option"));
    for (WebElement el : optionElements) {
        if (el.getText().equals(value)) {
            if (!el.isSelected()) {
                ((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) SeleniumOperationException(com.axway.ats.uiengine.exceptions.SeleniumOperationException) WebElement(org.openqa.selenium.WebElement) HtmlUnitWebElement(org.openqa.selenium.htmlunit.HtmlUnitWebElement) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 8 with HtmlUnitWebElement

use of org.openqa.selenium.htmlunit.HtmlUnitWebElement in project ats-framework by Axway.

the class HiddenHtmlMultiSelectList method getValues.

/**
     * @return the selected value
     */
@Override
@PublicAtsApi
public String[] getValues() {
    new HiddenHtmlElementState(this).waitToBecomeExisting();
    HtmlUnitWebElement selectElement = HiddenHtmlElementLocator.findElement(this);
    List<String> values = new ArrayList<String>();
    List<WebElement> optionElements = selectElement.findElements(By.tagName("option"));
    for (WebElement element : optionElements) {
        if (element.isSelected()) {
            values.add(element.getText());
        }
    }
    if (values.isEmpty()) {
        throw new SeleniumOperationException("There is no selected 'option' in " + this.toString());
    }
    return values.toArray(new String[0]);
}
Also used : HiddenHtmlElementState(com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState) HtmlUnitWebElement(org.openqa.selenium.htmlunit.HtmlUnitWebElement) ArrayList(java.util.ArrayList) 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 9 with HtmlUnitWebElement

use of org.openqa.selenium.htmlunit.HtmlUnitWebElement in project ats-framework by Axway.

the class HiddenHtmlMultiSelectList method unsetValue.

/**
     * unselect a value
     *
     * @param value the value to unselect
     */
@Override
@PublicAtsApi
public void unsetValue(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)) {
            if (el.isSelected()) {
                ((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 10 with HtmlUnitWebElement

use of org.openqa.selenium.htmlunit.HtmlUnitWebElement in project ats-framework by Axway.

the class HiddenHtmlCheckBox method unCheck.

/**
     * Uncheck the check box
     */
@Override
@PublicAtsApi
public void unCheck() {
    new HiddenHtmlElementState(this).waitToBecomeExisting();
    HtmlUnitWebElement element = HiddenHtmlElementLocator.findElement(this);
    if (!element.isEnabled()) {
        throw new UnsupportedOperationException("You may not uncheck 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)

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