Search in sources :

Example 1 with Robot

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()");
        }
    }
}
Also used : Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) ElementNotFoundException(com.axway.ats.uiengine.exceptions.ElementNotFoundException) WaitTimedOutError(org.fest.swing.exception.WaitTimedOutError) Container(java.awt.Container) Dialog(java.awt.Dialog) ContainerFixture(org.fest.swing.fixture.ContainerFixture) Robot(org.fest.swing.core.Robot) BasicRobot(org.fest.swing.core.BasicRobot) JInternalFrame(javax.swing.JInternalFrame)

Example 2 with Robot

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();
        }
    }
}
Also used : Condition(org.fest.swing.timing.Condition) IdeFrameImpl(com.intellij.openapi.wm.impl.IdeFrameImpl) IdeFrame(com.intellij.openapi.wm.IdeFrame) WindowFinder.findFrame(org.fest.swing.finder.WindowFinder.findFrame) ProgressManager(com.intellij.openapi.progress.ProgressManager) Robot(org.fest.swing.core.Robot) IdeFrame(com.intellij.openapi.wm.IdeFrame)

Example 3 with Robot

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);
}
Also used : Robot(org.fest.swing.core.Robot)

Example 4 with Robot

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);
}
Also used : JListFixture(org.fest.swing.fixture.JListFixture) Robot(org.fest.swing.core.Robot)

Example 5 with Robot

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);
    }
}
Also used : Robot(org.fest.swing.core.Robot)

Aggregations

Robot (org.fest.swing.core.Robot)13 BasicRobot (org.fest.swing.core.BasicRobot)7 ElementNotFoundException (com.axway.ats.uiengine.exceptions.ElementNotFoundException)2 ProgressManager (com.intellij.openapi.progress.ProgressManager)2 IdeFrame (com.intellij.openapi.wm.IdeFrame)2 IdeFrameImpl (com.intellij.openapi.wm.impl.IdeFrameImpl)2 Dialog (java.awt.Dialog)2 Frame (java.awt.Frame)2 JInternalFrame (javax.swing.JInternalFrame)2 GenericTypeMatcher (org.fest.swing.core.GenericTypeMatcher)2 WaitTimedOutError (org.fest.swing.exception.WaitTimedOutError)2 WindowFinder.findFrame (org.fest.swing.finder.WindowFinder.findFrame)2 ContainerFixture (org.fest.swing.fixture.ContainerFixture)2 JButtonFixture (org.fest.swing.fixture.JButtonFixture)2 Condition (org.fest.swing.timing.Condition)2 AWTEvent (java.awt.AWTEvent)1 Component (java.awt.Component)1 Container (java.awt.Container)1 AWTEventListener (java.awt.event.AWTEventListener)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1