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();
}
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;
}
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();
}
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();
}
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();
}
}
Aggregations