use of com.axway.ats.uiengine.exceptions.UiElementException in project ats-framework by Axway.
the class SwingTable method selectCells.
/**
* Select table cells
*
* @param cells the cells coordinates (eg. new int[][]{ { 1, 1 }, { 1, 2 }, { 2, 2 } )
* @throws VerificationException if the element doesn't exist
*/
@PublicAtsApi
public void selectCells(int[][] cells) {
new SwingElementState(this).waitToBecomeExisting();
JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this);
try {
TableCell[] cellsToSelect = new TableCell[cells.length];
for (int i = 0; i < cells.length; i++) {
int row = cells[i][0];
int column = cells[i][1];
cellsToSelect[i] = new TableCell(row, column) {
};
}
tableFixture.selectCells(cellsToSelect);
} 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 SwingSpinner method clickNext.
/**
* Click next/increment spinner button
* @param times number of times to click. Must be greater than 0
* @throws VerificationException if the element doesn't exist
*/
@PublicAtsApi
public void clickNext(int times) {
if (times <= 0) {
throw new UiElementException("The number of times to click must be greater than 0", this);
}
new SwingElementState(this).waitToBecomeExisting();
((JSpinnerFixture) SwingElementLocator.findFixture(this)).increment(times);
}
use of com.axway.ats.uiengine.exceptions.UiElementException in project ats-framework by Axway.
the class SwingComboBox method setValue.
/**
* Set ComboBox value
* @param value the ComboBox value to set
* @throws VerificationException if the element doesn't exist
*/
@SuppressWarnings("unchecked")
@Override
@PublicAtsApi
public void setValue(String value) {
new SwingElementState(this).waitToBecomeExisting();
JComboBoxFixture comboBoxFixture = null;
try {
comboBoxFixture = ((JComboBoxFixture) SwingElementLocator.findFixture(this));
comboBoxFixture.selectItem(value);
} catch (LocationUnavailableException lue) {
// if the element is editable we'll enter the new value
if (comboBoxFixture != null && comboBoxFixture.component().isEditable()) {
try {
comboBoxFixture.component().addItem(value);
comboBoxFixture.selectItem(value);
} catch (LocationUnavailableException e) {
throw new UiElementException(e.getMessage(), this);
}
} else {
throw new UiElementException(lue.getMessage(), this);
}
}
}
use of com.axway.ats.uiengine.exceptions.UiElementException in project ats-framework by Axway.
the class HtmlFileDownloader method downloadFile.
/**
* Perform the file/image download.
*
* @param downloadUrl
* @return download file absolute path
* @throws IOException
* @throws FileTransferClientException
*/
public String downloadFile(String downloadUrl) throws IOException {
if (StringUtils.isNullOrEmpty(downloadUrl)) {
throw new UiElementException("The element you have specified does not link to anything!");
}
URL url = new URL(downloadUrl);
String fileName = url.getPath();
if (fileName.indexOf('/') > -1) {
fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
}
HttpsClient httpsClient = new HttpsClient();
httpsClient.connect(url.getHost());
if (this.mimicWebDriverCookieState) {
for (org.openqa.selenium.Cookie cookie : this.webDriver.manage().getCookies()) {
httpsClient.addCookie(cookie.getName(), cookie.getValue(), cookie.getDomain(), cookie.getPath(), cookie.getExpiry(), cookie.isSecure());
}
if (this.webDriver instanceof org.openqa.selenium.phantomjs.PhantomJSDriver && System.getProperty(PhantomJsDriver.HTTP_ONLY_COOKIES_PROPERTY) != null) {
for (org.openqa.selenium.Cookie cookie : PhantomJsDriver.getHttpOnlyCookies()) {
httpsClient.addCookie(cookie.getName(), cookie.getValue(), cookie.getDomain(), cookie.getPath(), cookie.getExpiry(), cookie.isSecure());
}
}
}
File downloadedFile = new File(this.downloadDir + fileName);
log.debug("Downloading file: " + downloadedFile.getName());
org.apache.commons.io.FileUtils.copyInputStreamToFile(httpsClient.performGetRequest(url.getFile()), downloadedFile);
String downloadedFileAbsolutePath = downloadedFile.getAbsolutePath();
log.debug("File downloaded to '" + downloadedFileAbsolutePath + "'");
return downloadedFileAbsolutePath;
}
use of com.axway.ats.uiengine.exceptions.UiElementException in project ats-framework by Axway.
the class SwingSpinner method clickPrevious.
/**
* Click previous/decrement spinner button
* @param times number of times to click. Must be greater than 0
* @throws VerificationException if the element doesn't exist
*/
@PublicAtsApi
public void clickPrevious(int times) {
if (times <= 0) {
throw new UiElementException("The number of times to click must be greater than 0", this);
}
new SwingElementState(this).waitToBecomeExisting();
((JSpinnerFixture) SwingElementLocator.findFixture(this)).decrement(times);
}
Aggregations