Search in sources :

Example 6 with JSpinnerFixture

use of org.fest.swing.fixture.JSpinnerFixture in project ats-framework by Axway.

the class SwingSpinner method setValue.

/**
     * Set spinner text value (entering and committing the given text in the JSpinner)
     * @throws VerificationException if the element doesn't exist
     */
@PublicAtsApi
public void setValue(String value) {
    new SwingElementState(this).waitToBecomeExisting();
    JSpinnerFixture spinnerFixture = (JSpinnerFixture) SwingElementLocator.findFixture(this);
    int delayBetweenEvents = spinnerFixture.robot.settings().delayBetweenEvents();
    try {
        // enterTextAndCommit() method sets the text value using the Robot, so we will speed it up
        String delay = AtsSystemProperties.getPropertyAsString(AtsSystemProperties.UI_ENGINE__SWING_ROBOT_DELAY_BETWEEN_EVENTS);
        if (delay != null) {
            int ms = -1;
            try {
                ms = Integer.parseInt(delay);
            } catch (NumberFormatException ex) {
                log.error("Illegal robot dealy between events specified! Will be used default one", ex);
            }
            if (ms >= 0) {
                spinnerFixture.robot.settings().delayBetweenEvents(ms);
            }
        } else {
            // hardcode to 100ms
            spinnerFixture.robot.settings().delayBetweenEvents(100);
        }
        spinnerFixture.enterTextAndCommit(value);
    } finally {
        spinnerFixture.robot.settings().delayBetweenEvents(delayBetweenEvents);
    }
}
Also used : SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) JSpinnerFixture(org.fest.swing.fixture.JSpinnerFixture) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

JSpinnerFixture (org.fest.swing.fixture.JSpinnerFixture)6 PublicAtsApi (com.axway.ats.common.PublicAtsApi)4 SwingElementState (com.axway.ats.uiengine.utilities.swing.SwingElementState)4 UiElementException (com.axway.ats.uiengine.exceptions.UiElementException)2 ElementNotFoundException (com.axway.ats.uiengine.exceptions.ElementNotFoundException)1 SwingDriverInternal (com.axway.ats.uiengine.internal.driver.SwingDriverInternal)1 Component (java.awt.Component)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JComboBox (javax.swing.JComboBox)1 JLabel (javax.swing.JLabel)1 JList (javax.swing.JList)1 JMenuItem (javax.swing.JMenuItem)1 JOptionPane (javax.swing.JOptionPane)1 JPopupMenu (javax.swing.JPopupMenu)1 JRadioButton (javax.swing.JRadioButton)1 JSpinner (javax.swing.JSpinner)1 JTabbedPane (javax.swing.JTabbedPane)1 JTable (javax.swing.JTable)1 JToggleButton (javax.swing.JToggleButton)1