use of org.fest.swing.core.Robot in project ats-framework by Axway.
the class SwingElementLocator method getContainerFixture.
/**
* Change container by specified name or title.
* For internal use
* @param driver
* @param containerProperties property with name inside
* @return the {@link ContainerFinxture}
*/
public static ContainerFixture<?> getContainerFixture(SwingDriverInternal driver, UiElementProperties containerProperties) {
String containerName = containerProperties.getProperty("name");
final String containerTitle = containerProperties.getProperty("title");
if (StringUtils.isNullOrEmpty(containerName) && StringUtils.isNullOrEmpty(containerTitle)) {
throw new IllegalArgumentException("Illegal name/title (empty/null string) passed to search for container");
}
ContainerFixture<?> containerFixture = driver.getActiveContainerFixture();
ContainerFixture<?> windowsFixture = driver.getWindowFixture();
Robot robot = null;
if (containerFixture != null) {
// use the current robot instance
robot = containerFixture.robot;
} else {
robot = BasicRobot.robotWithCurrentAwtHierarchy();
}
if (!StringUtils.isNullOrEmpty(containerName)) {
try {
Container cont = BasicComponentFinder.finderWithCurrentAwtHierarchy().findByName(windowsFixture.component(), containerName, Container.class);
return new ContainerFixture<Container>(robot, cont) {
};
} catch (WaitTimedOutError wtoe) {
throw new ElementNotFoundException("Unable to find container with name '" + containerName + "' under current window/dialog. If needed change current window first with swingEngineInstance.setActiveWindow()");
}
} else {
try {
Container cont = BasicComponentFinder.finderWithCurrentAwtHierarchy().find(windowsFixture.component(), new GenericTypeMatcher<Container>(Container.class, true) {
@Override
protected boolean isMatching(Container component) {
if (component instanceof Dialog) {
return ((Dialog) component).getTitle().equals(containerTitle);
} else if (component instanceof Frame) {
return ((Frame) component).getTitle().equals(containerTitle);
} else if (component instanceof JInternalFrame) {
return ((JInternalFrame) component).getTitle().equals(containerTitle);
}
return false;
}
});
return new ContainerFixture<Container>(robot, cont) {
};
} catch (WaitTimedOutError wtoe) {
throw new ElementNotFoundException("Unable to find container with title '" + containerName + "' under current window/dialog. If needed change current window first with swingEngineInstance.setActiveWindow()");
}
}
}
use of org.fest.swing.core.Robot in project intellij-community by JetBrains.
the class GuiTestUtil method waitForIdeToStart.
// Called by IdeTestApplication via reflection.
@SuppressWarnings("UnusedDeclaration")
public static void waitForIdeToStart() {
GuiActionRunner.executeInEDT(false);
Robot robot = null;
try {
robot = BasicRobot.robotWithCurrentAwtHierarchy();
final MyProjectManagerListener listener = new MyProjectManagerListener();
//[ACCEPT IntelliJ IDEA Privacy Policy Agreement]
acceptAgreementIfNeeded(robot);
findFrame(new GenericTypeMatcher<Frame>(Frame.class) {
@Override
protected boolean isMatching(@NotNull Frame frame) {
if (frame instanceof IdeFrame) {
if (frame instanceof IdeFrameImpl) {
listener.myActive = true;
ProjectManager.getInstance().addProjectManagerListener(listener);
}
return true;
}
return false;
}
}).withTimeout(LONG_TIMEOUT.duration()).using(robot);
if (listener.myActive) {
Pause.pause(new Condition("Project to be opened") {
@Override
public boolean test() {
boolean notified = listener.myNotified;
if (notified) {
ProgressManager progressManager = ProgressManager.getInstance();
boolean isIdle = !progressManager.hasModalProgressIndicator() && !progressManager.hasProgressIndicator() && !progressManager.hasUnsafeProgressIndicator();
if (isIdle) {
ProjectManager.getInstance().removeProjectManagerListener(listener);
}
return isIdle;
}
return false;
}
}, LONG_TIMEOUT);
}
} finally {
GuiActionRunner.executeInEDT(true);
if (robot != null) {
robot.cleanUpWithoutDisposingWindows();
}
}
}
use of org.fest.swing.core.Robot in project intellij-community by JetBrains.
the class GuiTestUtil method findAndClickButton.
public static void findAndClickButton(@NotNull ContainerFixture<? extends Container> container, @NotNull final String text) {
Robot robot = container.robot();
JButton button = findButton(container, text, robot);
robot.click(button);
}
use of org.fest.swing.core.Robot in project android by JetBrains.
the class AddGradleDependencyTest method assertIntentionNotIncluded.
private void assertIntentionNotIncluded(@NotNull EditorFixture editor, @NotNull String intention) {
editor.invokeAction(SHOW_INTENTION_ACTIONS);
Robot robot = guiTest.robot();
JListFixture popup = new JListFixture(robot, waitForPopup(robot));
String[] intentions = popup.contents();
assertThat(intentions).asList().doesNotContain(intention);
}
use of org.fest.swing.core.Robot in project android by JetBrains.
the class WebpConversionDialogFixture method clickRadioButton.
private void clickRadioButton(String text) {
Robot robot = robot();
JRadioButton checkbox = robot.finder().find(target(), Matchers.byText(JRadioButton.class, text));
Wait.seconds(1).expecting("button " + text + " to be enabled").until(() -> checkbox.isEnabled() && checkbox.isVisible() && checkbox.isShowing());
if (!checkbox.isSelected()) {
robot.click(checkbox);
}
}
Aggregations