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);
}
}
Aggregations