use of com.axway.ats.uiengine.exceptions.UiElementException in project ats-framework by Axway.
the class SwingTabbedPane method selectTabUsingSubElement.
/**
* Select tab by title using SubElement described in the map file. The required property is 'title'
*
* @param mapId the sub-element mapID. This element must have property 'title'
* @throws VerificationException if the table element doesn't exist
*/
@PublicAtsApi
public void selectTabUsingSubElement(String mapId) {
new SwingElementState(this).waitToBecomeExisting();
try {
String elementMapId = properties.getInternalProperty(UiElementProperties.MAP_ID_INTERNAL_PARAM);
if (elementMapId == null) {
throw new UiElementException("The element must be in the MAP file", this);
}
UiElementProperties elProperties = ElementsMap.getInstance().getSubElementProperties(elementMapId, mapId);
String tabTitle = elProperties.getProperty("title");
if (tabTitle == null) {
throw new UiElementException("The Sub-Element doesn't have 'title' attribute, " + "which is required for tab selection.", this);
}
((JTabbedPaneFixture) SwingElementLocator.findFixture(this)).selectTab(tabTitle);
} catch (Exception e) {
throw new UiElementException(e.getMessage(), this);
}
}
use of com.axway.ats.uiengine.exceptions.UiElementException in project ats-framework by Axway.
the class SwingTabbedPane method selectTabUsingSubElement.
/**
* Select tab by title using sub-element properties. The required property is 'title'
*
* @param elementProperties the sub-element {@link UiElementProperties} which contains property 'title'
* @throws VerificationException if the table element doesn't exist
*/
@PublicAtsApi
public void selectTabUsingSubElement(UiElementProperties elementProperties) {
new SwingElementState(this).waitToBecomeExisting();
try {
String tabTitle = elementProperties.getProperty("title");
if (tabTitle == null) {
throw new UiElementException("The Sub-Element doesn't have 'title' attribute, " + "which is required for tab selection.", this);
}
((JTabbedPaneFixture) SwingElementLocator.findFixture(this)).selectTab(tabTitle);
} catch (Exception e) {
throw new UiElementException(e.getMessage(), this);
}
}
use of com.axway.ats.uiengine.exceptions.UiElementException in project ats-framework by Axway.
the class SwingTable method rightClickCell.
/**
* Right click on table cell
*
* @param row the row number
* @param column the column number
* @throws VerificationException if the table element doesn't exist
*/
@PublicAtsApi
public void rightClickCell(int row, int column) {
new SwingElementState(this).waitToBecomeExisting();
JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this);
try {
tableFixture.cell(new TableCell(row, column) {
}).rightClick();
} catch (Exception e) {
throw new UiElementException(e.getMessage(), this);
}
}
use of com.axway.ats.uiengine.exceptions.UiElementException in project ats-framework by Axway.
the class SwingTable method getCellIndexesByValue.
/**
* Get table cell coordinates by cell value
*
* @param value cell value to search for
* @param isRegEx if the value is a regular expression
* @return an {@link ArrayList} with cell coordinates(indexes) represented by arrays [ row, column ] which contains
* the searched value
* @throws VerificationException if the table element doesn't exist
*/
@PublicAtsApi
public List<Integer[]> getCellIndexesByValue(String value, boolean isRegEx) {
new SwingElementState(this).waitToBecomeExisting();
List<Integer[]> results = new ArrayList<Integer[]>();
JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this);
try {
if (value == null) {
isRegEx = false;
}
Pattern regexPattern = null;
if (isRegEx) {
regexPattern = Pattern.compile(value);
}
for (int row = 0; row < tableFixture.target.getRowCount(); row++) {
for (int column = 0; column < tableFixture.target.getColumnCount(); column++) {
String cellValue = null;
try {
cellValue = tableFixture.valueAt(new TableCell(row, column) {
});
} catch (NullPointerException npe) {
// valueAt() throws NPE if the cell is null
}
if (cellValue == null && value != null) {
continue;
}
if ((cellValue == null && value == null) || (isRegEx && regexPattern.matcher(cellValue).matches()) || (!isRegEx && cellValue.equals(value))) {
results.add(new Integer[] { row, column });
}
}
}
} catch (Exception e) {
throw new UiElementException(e.getMessage(), this);
}
return results;
}
use of com.axway.ats.uiengine.exceptions.UiElementException in project ats-framework by Axway.
the class SwingTable method getSelectedRows.
/**
* Get selected rows in the table
*
* @return an array with the selected rows
* @throws VerificationException if the table element doesn't exist
*/
@PublicAtsApi
public int[] getSelectedRows() {
new SwingElementState(this).waitToBecomeExisting();
JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this);
try {
return tableFixture.component().getSelectedRows();
} catch (Exception e) {
throw new UiElementException(e.getMessage(), this);
}
}
Aggregations