Search in sources :

Example 21 with SwingElementState

use of com.axway.ats.uiengine.utilities.swing.SwingElementState 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 22 with SwingElementState

use of com.axway.ats.uiengine.utilities.swing.SwingElementState in project ats-framework by Axway.

the class SwingTable method drag.

/**
 * Simulates a user dragging a cell from this table
 *
 * @param row the row number
 * @param column the column number
 */
@PublicAtsApi
public void drag(int row, int column) {
    new SwingElementState(this).waitToBecomeExisting();
    ((JTableFixture) SwingElementLocator.findFixture(this)).drag(new TableCell(row, column) {
    });
}
Also used : JTableFixture(org.fest.swing.fixture.JTableFixture) TableCell(org.fest.swing.data.TableCell) SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 23 with SwingElementState

use of com.axway.ats.uiengine.utilities.swing.SwingElementState 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)

Example 24 with SwingElementState

use of com.axway.ats.uiengine.utilities.swing.SwingElementState 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);
    }
}
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 25 with SwingElementState

use of com.axway.ats.uiengine.utilities.swing.SwingElementState in project ats-framework by Axway.

the class SwingMenuItem method click.

/**
 * Click menu item
 * @throws VerificationException if the element doesn't exist
 */
@Override
@PublicAtsApi
public void click() {
    new SwingElementState(this).waitToBecomeExisting();
    ((JMenuItemFixture) SwingElementLocator.findFixture(this)).click();
}
Also used : SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) JMenuItemFixture(org.fest.swing.fixture.JMenuItemFixture) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

PublicAtsApi (com.axway.ats.common.PublicAtsApi)60 SwingElementState (com.axway.ats.uiengine.utilities.swing.SwingElementState)60 UiElementException (com.axway.ats.uiengine.exceptions.UiElementException)16 JTableFixture (org.fest.swing.fixture.JTableFixture)16 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)12 TableCell (org.fest.swing.data.TableCell)12 NotSupportedOperationException (com.axway.ats.uiengine.exceptions.NotSupportedOperationException)11 VerifyNotEqualityException (com.axway.ats.uiengine.exceptions.VerifyNotEqualityException)11 VerifyEqualityException (com.axway.ats.uiengine.exceptions.VerifyEqualityException)10 JTreeFixture (org.fest.swing.fixture.JTreeFixture)8 JListFixture (org.fest.swing.fixture.JListFixture)7 JPopupMenuFixture (org.fest.swing.fixture.JPopupMenuFixture)5 JSpinnerFixture (org.fest.swing.fixture.JSpinnerFixture)4 ArrayList (java.util.ArrayList)2 ComponentDragAndDrop (org.fest.swing.core.ComponentDragAndDrop)2 JCheckBoxFixture (org.fest.swing.fixture.JCheckBoxFixture)2 JFileChooserFixture (org.fest.swing.fixture.JFileChooserFixture)2 JMenuItemFixture (org.fest.swing.fixture.JMenuItemFixture)2 JTabbedPaneFixture (org.fest.swing.fixture.JTabbedPaneFixture)2 JTableHeaderFixture (org.fest.swing.fixture.JTableHeaderFixture)2