Search in sources :

Example 16 with RealHtmlElementState

use of com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState in project ats-framework by Axway.

the class RealHtmlTable method getRowCount.

/**
     * @return how many rows this table has
     */
@Override
@PublicAtsApi
public int getRowCount() {
    new RealHtmlElementState(this).waitToBecomeExisting();
    String css = this.getElementProperty("_css");
    List<WebElement> elements = null;
    if (!StringUtils.isNullOrEmpty(css)) {
        css += " tr";
        elements = webDriver.findElements(By.cssSelector(css));
    } else {
        // get elements matching the following xpath
        elements = webDriver.findElements(By.xpath(properties.getInternalProperty(HtmlElementLocatorBuilder.PROPERTY_ELEMENT_LOCATOR) + "/tr | " + properties.getInternalProperty(HtmlElementLocatorBuilder.PROPERTY_ELEMENT_LOCATOR) + "/*/tr"));
    }
    return elements.size();
}
Also used : RealHtmlElementState(com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState) WebElement(org.openqa.selenium.WebElement) RemoteWebElement(org.openqa.selenium.remote.RemoteWebElement) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 17 with RealHtmlElementState

use of com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState in project ats-framework by Axway.

the class RealHtmlTable method getFieldValue.

/**
     * Get the value of the specified table field
     *
     * @param row the field row starting at 0
     * @param column the field column starting at 0
     * @return
     */
@Override
@PublicAtsApi
public String getFieldValue(int row, int column) {
    new RealHtmlElementState(this).waitToBecomeExisting();
    WebElement table = RealHtmlElementLocator.findElement(this);
    String script = "var table = arguments[0]; var row = arguments[1]; var col = arguments[2];" + "if (row > table.rows.length) { return \"Cannot access row \" + row + \" - table has \" + table.rows.length + \" rows\"; }" + "if (col > table.rows[row].cells.length) { return \"Cannot access column \" + col + \" - table row has \" + table.rows[row].cells.length + \" columns\"; }" + "return table.rows[row].cells[col];";
    Object value = ((JavascriptExecutor) webDriver).executeScript(script, table, row, column);
    if (value instanceof WebElement) {
        return ((WebElement) value).getText().trim();
    }
    return null;
}
Also used : RealHtmlElementState(com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) WebElement(org.openqa.selenium.WebElement) RemoteWebElement(org.openqa.selenium.remote.RemoteWebElement) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 18 with RealHtmlElementState

use of com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState in project ats-framework by Axway.

the class RealHtmlTextArea method appendValue.

/**
     * Append text to the current content of a Text Area
     * 
     * @param value
     */
@Override
@PublicAtsApi
public void appendValue(String value) {
    new RealHtmlElementState(this).waitToBecomeExisting();
    WebElement element = RealHtmlElementLocator.findElement(this);
    element.sendKeys(normalizeText(value));
    UiEngineUtilities.sleep();
}
Also used : RealHtmlElementState(com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState) WebElement(org.openqa.selenium.WebElement) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 19 with RealHtmlElementState

use of com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState in project ats-framework by Axway.

the class RealHtmlTextBox method appendValue.

/**
     * Append text to the current content of a Text Box
     * 
     * @param value
     */
@PublicAtsApi
public void appendValue(String value) {
    new RealHtmlElementState(this).waitToBecomeExisting();
    WebElement element = RealHtmlElementLocator.findElement(this);
    element.sendKeys(value);
    UiEngineUtilities.sleep();
}
Also used : RealHtmlElementState(com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState) WebElement(org.openqa.selenium.WebElement) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 20 with RealHtmlElementState

use of com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState in project ats-framework by Axway.

the class AbstractRealBrowserDriver method handleExpectedPopups.

/**
	 * <b>Note:</b> For internal use only
	 */
public void handleExpectedPopups() {
    while (!expectedPopupsQueue.isEmpty()) {
        IExpectedPopup expectedPopup = expectedPopupsQueue.poll();
        if (expectedPopup instanceof ExpectedAlert) {
            ExpectedAlert expectedAlert = (ExpectedAlert) expectedPopup;
            new RealHtmlElementState(new RealHtmlAlert(this)).waitToBecomeExisting();
            Alert alert = getAlert();
            if (expectedAlert.expectedText != null && !expectedAlert.expectedText.equals(alert.getText())) {
                throw new VerificationException("The expected alert message was: '" + expectedAlert.expectedText + "', but actually it is: '" + alert.getText() + "'");
            }
            alert.accept();
        } else if (expectedPopup instanceof ExpectedPrompt) {
            ExpectedPrompt expectedPrompt = (ExpectedPrompt) expectedPopup;
            new RealHtmlElementState(new RealHtmlPrompt(this)).waitToBecomeExisting();
            Alert prompt = getAlert();
            if (expectedPrompt.expectedText != null && !expectedPrompt.expectedText.equals(prompt.getText())) {
                throw new VerificationException("The expected prompt text was: '" + expectedPrompt.expectedText + "', but actually it is: '" + prompt.getText() + "'");
            }
            if (expectedPrompt.clickOk) {
                prompt.sendKeys(expectedPrompt.promptValueToSet);
                prompt.accept();
            } else {
                prompt.dismiss();
            }
        } else if (expectedPopup instanceof ExpectedConfirm) {
            ExpectedConfirm expectedConfirm = (ExpectedConfirm) expectedPopup;
            new RealHtmlElementState(new RealHtmlConfirm(this)).waitToBecomeExisting();
            Alert confirm = getAlert();
            if (expectedConfirm.expectedText != null && !expectedConfirm.expectedText.equals(confirm.getText())) {
                throw new VerificationException("The expected confirmation message was: '" + expectedConfirm.expectedText + "', but actually it is: '" + confirm.getText() + "'");
            }
            if (expectedConfirm.clickOk) {
                confirm.accept();
            } else {
                confirm.dismiss();
            }
        }
        UiEngineUtilities.sleep();
    }
}
Also used : RealHtmlElementState(com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState) RealHtmlAlert(com.axway.ats.uiengine.elements.html.realbrowser.RealHtmlAlert) ExpectedConfirm(com.axway.ats.uiengine.internal.realbrowser.ExpectedConfirm) RealHtmlConfirm(com.axway.ats.uiengine.elements.html.realbrowser.RealHtmlConfirm) ExpectedAlert(com.axway.ats.uiengine.internal.realbrowser.ExpectedAlert) VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) IExpectedPopup(com.axway.ats.uiengine.internal.realbrowser.IExpectedPopup) ExpectedAlert(com.axway.ats.uiengine.internal.realbrowser.ExpectedAlert) Alert(org.openqa.selenium.Alert) RealHtmlAlert(com.axway.ats.uiengine.elements.html.realbrowser.RealHtmlAlert) RealHtmlPrompt(com.axway.ats.uiengine.elements.html.realbrowser.RealHtmlPrompt) ExpectedPrompt(com.axway.ats.uiengine.internal.realbrowser.ExpectedPrompt)

Aggregations

RealHtmlElementState (com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState)34 PublicAtsApi (com.axway.ats.common.PublicAtsApi)31 WebElement (org.openqa.selenium.WebElement)30 SeleniumOperationException (com.axway.ats.uiengine.exceptions.SeleniumOperationException)7 Select (org.openqa.selenium.support.ui.Select)6 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)4 Actions (org.openqa.selenium.interactions.Actions)4 RemoteWebElement (org.openqa.selenium.remote.RemoteWebElement)4 AbstractRealBrowserDriver (com.axway.ats.uiengine.AbstractRealBrowserDriver)2 NoSuchElementException (org.openqa.selenium.NoSuchElementException)2 RealHtmlAlert (com.axway.ats.uiengine.elements.html.realbrowser.RealHtmlAlert)1 RealHtmlConfirm (com.axway.ats.uiengine.elements.html.realbrowser.RealHtmlConfirm)1 RealHtmlPrompt (com.axway.ats.uiengine.elements.html.realbrowser.RealHtmlPrompt)1 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)1 VerifyEqualityException (com.axway.ats.uiengine.exceptions.VerifyEqualityException)1 VerifyNotEqualityException (com.axway.ats.uiengine.exceptions.VerifyNotEqualityException)1 ExpectedAlert (com.axway.ats.uiengine.internal.realbrowser.ExpectedAlert)1 ExpectedConfirm (com.axway.ats.uiengine.internal.realbrowser.ExpectedConfirm)1 ExpectedPrompt (com.axway.ats.uiengine.internal.realbrowser.ExpectedPrompt)1 IExpectedPopup (com.axway.ats.uiengine.internal.realbrowser.IExpectedPopup)1