Search in sources :

Example 11 with SeleniumOperationException

use of com.axway.ats.uiengine.exceptions.SeleniumOperationException 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 12 with SeleniumOperationException

use of com.axway.ats.uiengine.exceptions.SeleniumOperationException 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 13 with SeleniumOperationException

use of com.axway.ats.uiengine.exceptions.SeleniumOperationException in project ats-framework by Axway.

the class AbstractHtmlEngine method switchToWindowByTitle.

private void switchToWindowByTitle(final String windowTitle, long timeoutInSeconds) {
    ExpectedCondition<Boolean> expectation = new ExpectedCondition<Boolean>() {

        public Boolean apply(WebDriver driver) {
            return switchToWindowByTitle(windowTitle);
        }
    };
    Wait<WebDriver> wait = new WebDriverWait(webDriver, timeoutInSeconds);
    try {
        wait.until(expectation);
    } catch (Exception e) {
        throw new SeleniumOperationException("Timeout waiting for Window with title '" + windowTitle + "' to appear.", e);
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) SeleniumOperationException(com.axway.ats.uiengine.exceptions.SeleniumOperationException) SeleniumOperationException(com.axway.ats.uiengine.exceptions.SeleniumOperationException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 14 with SeleniumOperationException

use of com.axway.ats.uiengine.exceptions.SeleniumOperationException in project ats-framework by Axway.

the class HiddenHtmlSingleSelectList method getAllPossibleValues.

/**
     * @return  a list with all possible selection values
     */
@Override
@PublicAtsApi
public List<String> getAllPossibleValues() {
    List<String> values = new ArrayList<String>();
    new HiddenHtmlElementState(this).waitToBecomeExisting();
    HtmlUnitWebElement selectElement = HiddenHtmlElementLocator.findElement(this);
    List<WebElement> optionElements = selectElement.findElements(By.tagName("option"));
    if (optionElements.size() > 0) {
        for (WebElement element : optionElements) {
            values.add(element.getText());
        }
        return values;
    }
    throw new SeleniumOperationException("There is no selectable 'option' in " + this.toString());
}
Also used : HiddenHtmlElementState(com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState) ArrayList(java.util.ArrayList) 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 15 with SeleniumOperationException

use of com.axway.ats.uiengine.exceptions.SeleniumOperationException in project ats-framework by Axway.

the class HiddenHtmlSingleSelectList method getValue.

/**
     * @return the single selection value
     */
@Override
@PublicAtsApi
public String getValue() {
    new HiddenHtmlElementState(this).waitToBecomeExisting();
    HtmlUnitWebElement selectElement = HiddenHtmlElementLocator.findElement(this);
    List<WebElement> optionElements = selectElement.findElements(By.tagName("option"));
    for (WebElement element : optionElements) {
        if (element.isSelected()) {
            return element.getText();
        }
    }
    throw new SeleniumOperationException("There is no selected 'option' in " + 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)

Aggregations

SeleniumOperationException (com.axway.ats.uiengine.exceptions.SeleniumOperationException)22 PublicAtsApi (com.axway.ats.common.PublicAtsApi)16 WebElement (org.openqa.selenium.WebElement)13 HiddenHtmlElementState (com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState)7 RealHtmlElementState (com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState)7 HtmlUnitWebElement (org.openqa.selenium.htmlunit.HtmlUnitWebElement)6 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Select (org.openqa.selenium.support.ui.Select)4 ElementNotFoundException (com.axway.ats.uiengine.exceptions.ElementNotFoundException)3 Field (java.lang.reflect.Field)3 URL (java.net.URL)3 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)2 VerifyEqualityException (com.axway.ats.uiengine.exceptions.VerifyEqualityException)2 VerifyNotEqualityException (com.axway.ats.uiengine.exceptions.VerifyNotEqualityException)2 IncorrectnessListener (com.gargoylesoftware.htmlunit.IncorrectnessListener)2 Page (com.gargoylesoftware.htmlunit.Page)2 WebClient (com.gargoylesoftware.htmlunit.WebClient)2 WebRequest (com.gargoylesoftware.htmlunit.WebRequest)2 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)2