Search in sources :

Example 21 with SeleniumOperationException

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

the class RealHtmlMultiSelectList method unsetValue.

/**
     * unselect a value
     *
     * @param value the value to unselect
     */
@Override
@PublicAtsApi
public void unsetValue(String value) {
    new RealHtmlElementState(this).waitToBecomeExisting();
    WebElement element = RealHtmlElementLocator.findElement(this);
    Select select = new Select(element);
    // select.deselectByVisibleText( value ); // this method doesn't throw an exception if the option doesn't exist
    for (WebElement option : select.getOptions()) {
        if (option.getText().equals(value)) {
            if (option.isSelected()) {
                option.click();
                UiEngineUtilities.sleep();
            }
            return;
        }
    }
    throw new SeleniumOperationException("Option with label '" + value + "' not found. (" + this.toString() + ")");
}
Also used : RealHtmlElementState(com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState) Select(org.openqa.selenium.support.ui.Select) WebElement(org.openqa.selenium.WebElement) SeleniumOperationException(com.axway.ats.uiengine.exceptions.SeleniumOperationException) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 22 with SeleniumOperationException

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

the class RealHtmlMultiSelectList method setValue.

/**
     * select a value
     *
     * @param value the value to select
     */
@Override
@PublicAtsApi
public void setValue(String value) {
    new RealHtmlElementState(this).waitToBecomeExisting();
    try {
        WebElement element = RealHtmlElementLocator.findElement(this);
        Select select = new Select(element);
        select.selectByVisibleText(value);
    } catch (NoSuchElementException nsee) {
        throw new SeleniumOperationException("Option with label '" + value + "' not found. (" + this.toString() + ")");
    }
    UiEngineUtilities.sleep();
}
Also used : RealHtmlElementState(com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState) Select(org.openqa.selenium.support.ui.Select) WebElement(org.openqa.selenium.WebElement) SeleniumOperationException(com.axway.ats.uiengine.exceptions.SeleniumOperationException) NoSuchElementException(org.openqa.selenium.NoSuchElementException) 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