Search in sources :

Example 1 with UiElementException

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;
}
Also used : HttpsClient(com.axway.ats.core.filetransfer.HttpsClient) UiElementException(com.axway.ats.uiengine.exceptions.UiElementException) File(java.io.File) URL(java.net.URL)

Example 2 with UiElementException

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

the class SwingTable method clickHeader.

/**
     * Click table header by column index
     *
     * @param columnIndex the column index
     * @throws VerificationException if the table element doesn't exist
     */
@PublicAtsApi
public void clickHeader(int columnIndex) {
    new SwingElementState(this).waitToBecomeExisting();
    JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this);
    JTableHeaderFixture tableHeaderFixture = tableFixture.tableHeader();
    try {
        tableHeaderFixture.clickColumn(columnIndex);
    } catch (Exception e) {
        throw new UiElementException(e.getMessage(), this);
    }
}
Also used : JTableFixture(org.fest.swing.fixture.JTableFixture) SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) UiElementException(com.axway.ats.uiengine.exceptions.UiElementException) JTableHeaderFixture(org.fest.swing.fixture.JTableHeaderFixture) VerifyNotEqualityException(com.axway.ats.uiengine.exceptions.VerifyNotEqualityException) VerifyEqualityException(com.axway.ats.uiengine.exceptions.VerifyEqualityException) VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) UiElementException(com.axway.ats.uiengine.exceptions.UiElementException) NotSupportedOperationException(com.axway.ats.uiengine.exceptions.NotSupportedOperationException) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 3 with UiElementException

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

the class SwingTable method clickCell.

/**
     * Click table cell
     *
     * @param row the row number
     * @param column the column number
     * @throws VerificationException if the table element doesn't exist
     */
@PublicAtsApi
public void clickCell(int row, int column) {
    new SwingElementState(this).waitToBecomeExisting();
    JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this);
    try {
        tableFixture.cell(new TableCell(row, column) {
        }).click();
    } catch (Exception e) {
        throw new UiElementException(e.getMessage(), this);
    }
}
Also used : JTableFixture(org.fest.swing.fixture.JTableFixture) TableCell(org.fest.swing.data.TableCell) SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) UiElementException(com.axway.ats.uiengine.exceptions.UiElementException) VerifyNotEqualityException(com.axway.ats.uiengine.exceptions.VerifyNotEqualityException) VerifyEqualityException(com.axway.ats.uiengine.exceptions.VerifyEqualityException) VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) UiElementException(com.axway.ats.uiengine.exceptions.UiElementException) NotSupportedOperationException(com.axway.ats.uiengine.exceptions.NotSupportedOperationException) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 4 with UiElementException

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

the class SwingTable method doubleClickCell.

/**
     * Double click table cell
     *
     * @param row the row number
     * @param column the column number
     * @throws VerificationException if the element doesn't exist
     */
@PublicAtsApi
public void doubleClickCell(int row, int column) {
    new SwingElementState(this).waitToBecomeExisting();
    JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this);
    try {
        tableFixture.cell(new TableCell(row, column) {
        }).doubleClick();
    } catch (Exception e) {
        throw new UiElementException(e.getMessage(), this);
    }
}
Also used : JTableFixture(org.fest.swing.fixture.JTableFixture) TableCell(org.fest.swing.data.TableCell) SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) UiElementException(com.axway.ats.uiengine.exceptions.UiElementException) VerifyNotEqualityException(com.axway.ats.uiengine.exceptions.VerifyNotEqualityException) VerifyEqualityException(com.axway.ats.uiengine.exceptions.VerifyEqualityException) VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) UiElementException(com.axway.ats.uiengine.exceptions.UiElementException) NotSupportedOperationException(com.axway.ats.uiengine.exceptions.NotSupportedOperationException) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 5 with UiElementException

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

the class SwingTable method setFieldValue.

/**
     * Set table field value
     *
     * @param value the value to set
     * @param row the row number
     * @param column the column number
     * @throws VerificationException if the element doesn't exist
     */
@Override
@PublicAtsApi
public void setFieldValue(String value, int row, int column) {
    new SwingElementState(this).waitToBecomeExisting();
    JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this);
    try {
        TableCell tableCell = new TableCell(row, column) {
        };
        // if the cell coordinates are wrong, the exception will be thrown
        tableFixture.selectCell(tableCell);
        if (tableFixture.component().isCellEditable(row, column)) {
            tableFixture.enterValue(tableCell, value);
        } else {
            throw new NotSupportedOperationException("The table cell [" + row + "," + column + "] is not editable. " + toString());
        }
    } catch (IndexOutOfBoundsException ioobe) {
        throw new UiElementException(ioobe.getMessage(), this);
    }
}
Also used : JTableFixture(org.fest.swing.fixture.JTableFixture) TableCell(org.fest.swing.data.TableCell) SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) UiElementException(com.axway.ats.uiengine.exceptions.UiElementException) NotSupportedOperationException(com.axway.ats.uiengine.exceptions.NotSupportedOperationException) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

UiElementException (com.axway.ats.uiengine.exceptions.UiElementException)18 PublicAtsApi (com.axway.ats.common.PublicAtsApi)16 SwingElementState (com.axway.ats.uiengine.utilities.swing.SwingElementState)16 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)13 NotSupportedOperationException (com.axway.ats.uiengine.exceptions.NotSupportedOperationException)11 JTableFixture (org.fest.swing.fixture.JTableFixture)11 VerifyEqualityException (com.axway.ats.uiengine.exceptions.VerifyEqualityException)10 VerifyNotEqualityException (com.axway.ats.uiengine.exceptions.VerifyNotEqualityException)10 TableCell (org.fest.swing.data.TableCell)7 ArrayList (java.util.ArrayList)2 JSpinnerFixture (org.fest.swing.fixture.JSpinnerFixture)2 JTabbedPaneFixture (org.fest.swing.fixture.JTabbedPaneFixture)2 JTableHeaderFixture (org.fest.swing.fixture.JTableHeaderFixture)2 HttpsClient (com.axway.ats.core.filetransfer.HttpsClient)1 UiElementProperties (com.axway.ats.uiengine.elements.UiElementProperties)1 File (java.io.File)1 URL (java.net.URL)1 Pattern (java.util.regex.Pattern)1 LocationUnavailableException (org.fest.swing.exception.LocationUnavailableException)1 JComboBoxFixture (org.fest.swing.fixture.JComboBoxFixture)1