public static GW4EProject create (SWTWorkbenchBot bot,String gwproject) throws CoreException, FileNotFoundException { GW4EProject project = new GW4EProject(bot, gwproject); project.resetToJavPerspective(); project.createProject(); File path = new File("src/test/resources/petclinic"); IContainer destFolder = (IContainer) ResourceManager.getResource(gwproject+ "/src/test/resources"); ImportHelper.copyFiles(path,destFolder); String[] folders = PreferenceManager.getAuthorizedFolderForGraphDefinition(); String[] temp = new String[2]; temp[0] = gwproject; temp[1] = folders[1]; project.generateSource(temp); bot.waitUntil(new EditorOpenedCondition(bot, "VeterinariensSharedStateImpl.java"), 3 * 60000); project.waitForBuildAndAssertNoErrors(); return project; }
public static void openNewGraphWalkerModel(SWTWorkbenchBot bot) { SWTBotMenu all = bot.menu("File").menu("New"); /* Function<String, String> f = new Function<String, String> () { @Override public String apply(String t) { return t; } }; all.menuItems().stream().map(f); */ bot.menu("File").menu("New").menu("GW4E Model").click(); bot.waitUntil(new ShellActiveCondition("GW4E")); SWTBotShell shell = bot.shell("GW4E"); assertTrue(shell.isOpen()); shell.bot().button("Cancel").click(); bot.waitUntil(Conditions.shellCloses(shell)); }
public static boolean hasErrorsInProblemsView(SWTWorkbenchBot bot) { // Open Problems View by Window -> show view -> Problems bot.menu("Window").menu("Show View").menu("Problems").click(); SWTBotView view = bot.viewByTitle("Problems"); view.show(); SWTBotTree tree = view.bot().tree(); for (SWTBotTreeItem item : tree.getAllItems()) { String text = item.getText(); if (text != null && text.startsWith("Errors")) { return true; } } return false; }
/** * Opens the preferences dialog from the main Eclipse window. * <p> * Note: There are some platform-specific intricacies that this abstracts * away. */ public static void openPreferencesDialog(final SWTWorkbenchBot bot) { SwtBotTestingUtilities.performAndWaitForWindowChange(bot, new Runnable() { @Override public void run() { if (SwtBotTestingUtilities.isMac()) { // TODO: Mac has "Preferences..." under the "Eclipse" menu item. // However, // the "Eclipse" menu item is a system menu item (like the Apple menu // item), and can't be reached via SWTBot. openPreferencesDialogViaEvents(bot); } else { SWTBotMenu windowMenu = bot.menu("Window"); windowMenu.menu("Preferences").click(); } } }); }
/** * Wait until a tree item contains a child with the given text. * * @throws TimeoutException if the child does not appear within the default timeout */ public static void waitUntilTreeItemHasChild(SWTWorkbenchBot bot, final SWTBotTreeItem treeItem, final String childText) { bot.waitUntil(new DefaultCondition() { @Override public String getFailureMessage() { System.err.println(treeItem + ": expanded? " + treeItem.isExpanded()); for (SWTBotTreeItem childNode : treeItem.getItems()) { System.err.println(" " + childNode); } return "Tree item never appeared"; } @Override public boolean test() throws Exception { return treeItem.getNodes().contains(childText); } }); }
/** * Wait until the tree item contains the given text with the timeout specified. */ public static void waitUntilTreeContainsText(SWTWorkbenchBot bot, final SWTBotTreeItem treeItem, final String text, long timeout) { bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { return treeItem.getText().contains(text); } @Override public String getFailureMessage() { return "Text never appeared"; } }, timeout); }
/** * Creates a Java class with the specified name. * * @param projectName the name of the project the class should be created in * @param sourceFolder the name of the source folder in which the class should be created. * Typically "src" for normal Java projects, or "src/main/java" for Maven projects * @param packageName the name of the package the class should be created in * @param className the name of the class to be created */ public static void createJavaClass(final SWTWorkbenchBot bot, String sourceFolder, String projectName, String packageName, final String className) { SWTBotTreeItem project = SwtBotProjectActions.selectProject(bot, projectName); selectProjectItem(project, sourceFolder, packageName).select(); SwtBotTestingUtilities.performAndWaitForWindowChange(bot, new Runnable() { @Override public void run() { MenuItem menuItem = ContextMenuHelper.contextMenu(getProjectRootTree(bot), "New", "Class"); new SWTBotMenu(menuItem).click(); } }); SwtBotTestingUtilities.performAndWaitForWindowChange(bot, new Runnable() { @Override public void run() { bot.activeShell(); bot.textWithLabel("Name:").setText(className); SwtBotTestingUtilities.clickButtonAndWaitForWindowClose(bot, bot.button("Finish")); } }); }
private static void openImportProjectsWizard(SWTWorkbenchBot bot, String wizardCategory, String importWizardName) { for (int tries = 1; true; tries++) { SWTBotShell shell = null; try { bot.menu("File").menu("Import...").click(); shell = bot.shell("Import"); shell.activate(); SwtBotTreeUtilities.waitUntilTreeHasItems(bot, bot.tree()); SWTBotTreeItem treeItem = bot.tree().expandNode(wizardCategory); SwtBotTreeUtilities.waitUntilTreeItemHasChild(bot, treeItem, importWizardName); treeItem.select(importWizardName); break; } catch (TimeoutException e) { if (tries == 2) { throw e; } else if (shell != null) { shell.close(); } } } }
/** * Import a Maven project from a zip file */ public static IProject importMavenProject(SWTWorkbenchBot bot, String projectName, File extractedLocation) { openImportProjectsWizard(bot, "Maven", "Existing Maven Projects"); bot.button("Next >").click(); bot.comboBoxWithLabel("Root Directory:").setText(extractedLocation.getAbsolutePath()); bot.button("Refresh").click(); try { SwtBotTestingUtilities.clickButtonAndWaitForWindowClose(bot, bot.button("Finish")); } catch (TimeoutException ex) { System.err.println("FATAL: timed out while waiting for the wizard to close. Forcibly killing " + "all shells: https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/1925"); System.err.println("FATAL: You will see tons of related errors: \"Widget is disposed\", " + "\"Failed to execute runnable\", \"IllegalStateException\", etc."); SwtBotWorkbenchActions.killAllShells(bot); throw ex; } SwtBotTimeoutManager.resetTimeout(); IProject project = waitUntilFacetedProjectExists(bot, getWorkspaceRoot().getProject(projectName)); SwtBotWorkbenchActions.waitForProjects(bot, project); return project; }
/** * Tests if a shell with a specific type of data contained (e.g. Window). * * @param bot * to use * @param clazz * class of data contained to check for */ @SuppressWarnings("rawtypes") public static void assertShellWithDataTypeVisible(final SWTWorkbenchBot bot, final Class clazz) { bot.waitUntil(Conditions.waitForShell(new BaseMatcher<Shell>() { @SuppressWarnings("unchecked") public boolean matches(final Object item) { return UIThreadRunnable.syncExec(new Result<Boolean>() { public Boolean run() { if (item instanceof Shell) { Object shellData = ((Shell) item).getData(); if (shellData != null) { return clazz.isAssignableFrom(shellData.getClass()); } } return false; } }); } public void describeTo(final Description description) { description.appendText("Shell for " + clazz.getName()); } })); }
/** * Open view. * * @param bot * to work with, must not be {@code null} * @param category * the category, must not be {@code null} * @param view * the name of the view, must not be {@code null} */ public static void openView(final SWTWorkbenchBot bot, final String category, final String view) { Assert.isNotNull(bot, ARGUMENT_BOT); Assert.isNotNull(category, "category"); Assert.isNotNull(view, ARGUMENT_VIEW); bot.menu("Window").menu("Show View").menu("Other...").click(); bot.shell("Show View").activate(); final SWTBotTree tree = bot.tree(); for (SWTBotTreeItem item : tree.getAllItems()) { if (category.equals(item.getText())) { CoreSwtbotTools.waitForItem(bot, item); final SWTBotTreeItem[] node = item.getItems(); for (SWTBotTreeItem swtBotTreeItem : node) { if (view.equals(swtBotTreeItem.getText())) { swtBotTreeItem.select(); } } } } assertTrue("View or Category found", bot.button().isEnabled()); bot.button("OK").click(); }
/** * Waits until the node collapses. * * @param bot * bot to work with, must not be {@code null} * @param node * node to wait for, must not be {@code null} */ public static void safeBlockingCollapse(final SWTWorkbenchBot bot, final SWTBotTreeItem node) { Assert.isNotNull(bot, ARGUMENT_BOT); Assert.isNotNull(node, ARGUMENT_NODE); if (node.isExpanded()) { node.collapse(); try { bot.waitUntil(new DefaultCondition() { @Override @SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation") public boolean test() { return !node.isExpanded(); } @Override public String getFailureMessage() { return "Timeout for node to collapse"; } }, TIMEOUT_FOR_NODE_TO_COLLAPSE_EXPAND); } catch (TimeoutException e) { // Try one last time and do not wait anymore node.collapse(); } } }
/** * Pre flight initialization (run once for each test _case_) */ @Before public void setUp() throws Exception { // Force shell activation to counter, no active Shell when running SWTBot tests in Xvfb/Xvnc // see https://wiki.eclipse.org/SWTBot/Troubleshooting#No_active_Shell_when_running_SWTBot_tests_in_Xvfb Display.getDefault().syncExec(new Runnable() { public void run() { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().forceActive(); } }); bot = new SWTWorkbenchBot(); // Wait for the Toolbox shell to be available final Matcher<Shell> withText = withText("TLA+ Toolbox"); bot.waitUntil(Conditions.waitForShell(withText), 30000); // Wait for the Toolbox UI to be fully started. final Matcher<MenuItem> withMnemonic = WidgetMatcherFactory.withMnemonic("File"); final Matcher<MenuItem> matcher = WidgetMatcherFactory.allOf(WidgetMatcherFactory.widgetOfType(MenuItem.class), withMnemonic); bot.waitUntil(Conditions.waitForMenu(bot.shell("TLA+ Toolbox"), matcher), 30000); }
@BeforeClass public static void beforeClass() throws Exception { RCPTestSetupHelper.beforeClass(); // Force shell activation to counter, no active Shell when running SWTBot tests in Xvfb/Xvnc // see https://wiki.eclipse.org/SWTBot/Troubleshooting#No_active_Shell_when_running_SWTBot_tests_in_Xvfb Display.getDefault().syncExec(new Runnable() { public void run() { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().forceActive(); } }); bot = new SWTWorkbenchBot(); // Wait for the Toolbox shell to be available final Matcher<Shell> withText = withText("TLA+ Toolbox"); bot.waitUntil(Conditions.waitForShell(withText), 30000); // Wait for the Toolbox UI to be fully started. final Matcher<MenuItem> withMnemonic = WidgetMatcherFactory.withMnemonic("File"); final Matcher<MenuItem> matcher = WidgetMatcherFactory.allOf(WidgetMatcherFactory.widgetOfType(MenuItem.class), withMnemonic); bot.waitUntil(Conditions.waitForMenu(bot.shell("TLA+ Toolbox"), matcher), 30000); }
public static void beforeClass() { UIThreadRunnable.syncExec(new VoidResult() { public void run() { resetWorkbench(); resetToolbox(); // close browser-based welcome screen (if open) SWTWorkbenchBot bot = new SWTWorkbenchBot(); try { SWTBotView welcomeView = bot.viewByTitle("Welcome"); welcomeView.close(); } catch (WidgetNotFoundException e) { return; } } }); }
@BeforeClass public static void beforeClass() throws Exception { // If this assert fails see http://wiki.eclipse.org/JDT_weaving_features final String osgiFrameworkExtensions = System.getProperty("osgi.framework.extensions"); Assert.assertNotNull( "Test requires Aspectj weaving hook property to be present as an indicator for active weaving support", osgiFrameworkExtensions); // Reset the workbench RCPTestSetupHelper.beforeClass(); // check to make sure the given spec files exist Assert.assertTrue("Given spec file does not exist: " + specA, new File( specA).exists()); Assert.assertTrue("Given spec file does not exist: " + specA, new File( specB).exists()); bot = new SWTWorkbenchBot(); }
/** * Opens the preferences dialog from the main Eclipse window. * <p> * Note: There are some platform-specific intricacies that this abstracts * away. */ public static void openPreferencesDialog(final SWTWorkbenchBot bot) { SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() { @Override public void run() { if (SwtBotUtils.isMac()) { // TODO: Mac has "Preferences..." under the "Eclipse" menu item. // However, // the "Eclipse" menu item is a system menu item (like the Apple menu // item), and can't be reached via SWTBot. openPreferencesDialogViaEvents(bot); } else { SWTBotMenu windowMenu = bot.menu("Window"); windowMenu.menu("Preferences").click(); } } }); }
/** * Create a GWT project from Maven Archetype. * * Archetype: https://github.com/branflake2267/Archetypes/tree/master/archetypes/gwt-basic */ public static void createMavenGwtProjectIsCreated1(SWTWorkbenchBot bot, String projectName, String packageName) { // And create a maven project using an archetype String groupId = projectName; String artifactId = projectName; String archetypeGroupId = "com.github.branflake2267.archetypes"; String archetypeArtifactId = "gwt-test-gwt27-archetype"; String archetypeVersion = "1.0-SNAPSHOT"; String archetypeUrl = "https://oss.sonatype.org/content/repositories/snapshots"; SwtBotProjectActions.createMavenProjectFromArchetype(bot, groupId, artifactId, packageName, archetypeGroupId, archetypeArtifactId, archetypeVersion, archetypeUrl); // And wait for the project to finish setting up SwtBotWorkbenchActions.waitForIdle(bot); }
/** * Create a GWT project from Maven Archetype. * * Archetype: https://github.com/branflake2267/Archetypes/tree/master/archetypes/gwt-basic */ public static void createMavenGwtProjectIsCreated2(SWTWorkbenchBot bot, String projectName, String packageName) { // And create a maven project using an archetype String groupId = packageName; String artifactId = projectName; String archetypeGroupId = "com.github.branflake2267.archetypes"; String archetypeArtifactId = "gwt-basic-archetype"; String archetypeVersion = "2.0-SNAPSHOT"; String archetypeUrl = "https://oss.sonatype.org/content/repositories/snapshots"; SwtBotProjectActions.createMavenProjectFromArchetype(bot, groupId, artifactId, packageName, archetypeGroupId, archetypeArtifactId, archetypeVersion, archetypeUrl); // And wait for the project to finish setting up SwtBotWorkbenchActions.waitForIdle(bot); }
/** * Create a java project with the specified project name. This function opens up the Java * Perspective. * * @param bot The current SWTWorkbenchBot object * @param projectName Name of java project to be created */ public static void createJavaProject(SWTWorkbenchBot bot, String projectName) { // Open Java Perspective bot.perspectiveById("org.eclipse.jdt.ui.JavaPerspective").activate(); // Open the list of new project wizards bot.menu("File").menu("New").menu("Project...").click(); // Select the Java project SWTBotTree projectSelectionTree = bot.tree(); SWTBotTreeItem projectSelectionTreeItem = SwtBotTreeActions.getUniqueTreeItem(bot, projectSelectionTree, "Java", "Java Project"); SwtBotTreeActions.selectTreeItem(bot, projectSelectionTreeItem, "Java Project"); bot.button("Next >").click(); // Configure the project and then create it bot.textWithLabel("Project name:").setText(projectName); SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Finish")); }
public static void openPerspective(SWTWorkbenchBot bot, String perspectiveLabel) { SwtBotUtils.print("Opening Perspective: " + perspectiveLabel); SWTBotShell shell = null; try { menu(bot, "Window").menu("Open Perspective").menu("Other...").click(); shell = bot.shell("Open Perspective"); bot.waitUntil(ActiveWidgetCondition.widgetMakeActive(shell)); shell.bot().table().select(perspectiveLabel); shell.bot().button("OK").click(); bot.waitUntil(Conditions.shellCloses(shell)); } catch (Exception e) { if (shell != null && shell.isOpen()) shell.close(); SwtBotUtils.printError("Couldn't open perspective '" + perspectiveLabel + "'\n" + "trying to activate already open perspective instead"); // maybe somehow the perspective is already opened (by another test before us) SWTBotPerspective perspective = bot.perspectiveByLabel(perspectiveLabel); perspective.activate(); } SwtBotUtils.print("Opened Perspective: " + perspectiveLabel); }
public static String getTheProgramArgsTextBox(SWTWorkbenchBot bot) { SwtBotUtils.print("Retrieve Args"); // When I open debug configuration SwtBotMenuActions.openDebugConfiguration(bot); // Focus on the Arguments Tab bot.cTabItem("Arguments").activate().setFocus(); // Get the program arguments SWTBotText programArgs = bot.textInGroup("Program arguments:"); String text = programArgs.getText(); // And close the debug configuration dialog bot.button("Close").click(); // And closing may cause a save change dialog SwtBotProjectDebug.closeSaveChangesDialogIfNeedBe(bot); SwtBotUtils.print("Retrieved Args"); return text; }
/** * Creates a java class with the specified name. * * @param bot The SWTWorkbenchBot. * @param projectName The name of the project the class should be created in. * @param packageName The name of the package the class should be created in. * @param className The name of the java class to be created. */ public static void createJavaClass(final SWTWorkbenchBot bot, String projectName, String packageName, final String className) { SWTBotTreeItem project = SwtBotProjectActions.selectProject(bot, projectName); selectProjectItem(project, SOURCE_FOLDER, packageName).select(); SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() { @Override public void run() { MenuItem menuItem = ContextMenuHelper.contextMenu(getProjectRootTree(bot), "New", "Class"); new SWTBotMenu(menuItem).click(); } }); SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() { @Override public void run() { bot.activeShell(); bot.textWithLabel("Name:").setText(className); SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Finish")); } }); }
/** * Creates a java project with the specified project name. * * @param bot the SWTWorkbenchBot * @param projectName the name of the java project to create */ public static void createJavaProject(SWTWorkbenchBot bot, String projectName) { // Open Java Perspective bot.perspectiveById("org.eclipse.jdt.ui.JavaPerspective").activate(); // Open the list of new project wizards bot.menu("File").menu("New").menu("Project...").click(); // Select the Java project SWTBotTree projectSelectionTree = bot.tree(); SWTBotTreeItem projectSelectionGoogleTreeItem = SwtBotTreeActions.getUniqueTreeItem(bot, projectSelectionTree, "Java", "Java Project"); SwtBotTreeActions.selectTreeItem(bot, projectSelectionGoogleTreeItem, "Java Project"); bot.button("Next >").click(); // Configure the project and then create it bot.textWithLabel("Project name:").setText(projectName); SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Finish")); }
public static void createUiBinder(final SWTWorkbenchBot bot, String projectName, String packageName, String name, boolean generateSampleContent, boolean generateComments) { // Open the list of new project wizards bot.menu("File").menu("New").menu("Other...").click(); // Select the Web App project wizard SWTBotTree projectSelectionTree = bot.tree(); SWTBotTreeItem projectSelectionGoogleTreeItem = SwtBotTreeActions .getUniqueTreeItem(bot, projectSelectionTree, "GWT Classes", "UiBinder").expand(); SwtBotTreeActions.selectTreeItem(bot, projectSelectionGoogleTreeItem, "UiBinder"); bot.button("Next >").click(); // Configure the UiBinder and then create it String sourceFolder = projectName + "/" + SOURCE_FOLDER; bot.textWithLabel("Source folder:").setText(sourceFolder); bot.textWithLabel("Package:").setText(packageName); bot.textWithLabel("Name:").setText(name); SwtBotUtils.setCheckBox(bot.checkBox("Generate sample content"), generateSampleContent); SwtBotUtils.setCheckBox(bot.checkBox("Generate comments"), generateComments); SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Finish")); }
public static void deleteProject(final SWTWorkbenchBot bot, final String projectName) { SwtBotUtils.print("Deleting project " + projectName); // delete the launch configs created deleteLaunchConfigs(bot); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); try { project.delete(true, null); } catch (CoreException e) { SwtBotUtils.printError("Could not delete project"); } SwtBotWorkbenchActions.waitForIdle(bot); SwtBotUtils.print("Deleted project " + projectName); }
/** * Returns true if the specified project can be found in the 'Package Explorer' or 'Project View', * otherwise returns false. Throws a WidgetNotFoundException exception if the 'Package Explorer' * or 'Project Explorer' view cannot be found. * * @param bot The SWTWorkbenchBot. * @param projectName The name of the project to be found. * @return if the project exists */ public static boolean doesProjectExist(final SWTWorkbenchBot bot, String projectName) { SWTBotView explorer = getPackageExplorer(bot); if (explorer == null) { throw new WidgetNotFoundException( "Could not find the 'Package Explorer' or 'Project Explorer' view."); } // Select the root of the project tree in the explorer view Widget explorerWidget = explorer.getWidget(); Tree explorerTree = bot.widget(widgetOfType(Tree.class), explorerWidget); SWTBotTreeItem[] allItems = new SWTBotTree(explorerTree).getAllItems(); for (int i = 0; i < allItems.length; i++) { if (allItems[i].getText().equals(projectName)) { return true; } } return false; }
/** * Returns true if there are errors in the Problem view. Returns false otherwise. */ public static boolean hasErrorsInProblemsView(SWTWorkbenchBot bot) { // Open Problems View by Window -> show view -> Problems bot.menu("Window").menu("Show View").menu("Problems").click(); SWTBotView view = bot.viewByTitle("Problems"); view.show(); SWTBotTree tree = view.bot().tree(); for (SWTBotTreeItem item : tree.getAllItems()) { String text = item.getText(); if (text != null && text.startsWith("Errors")) { return true; } } return false; }
/** * Returns the specified project. Throws a WidgetNotFoundException if the 'Package Explorer' or * 'Project Explorer' view cannot be found or if the specified project cannot be found. * * @param bot The SWTWorkbenchBot. * @param projectName The name of the project to select. * @return the tree */ public static SWTBotTreeItem selectProject(final SWTWorkbenchBot bot, String projectName) { /* * Choose either the Package Explorer View or the Project Explorer view. Eclipse 3.3 and 3.4 * start with the Java Perspective, which has the Package Explorer View open by default, whereas * Eclipse 3.5 starts with the Resource Perspective, which has the Project Explorer View open. */ SWTBotView explorer = getPackageExplorer(bot); for (SWTBotView view : bot.views()) { if (view.getTitle().equals("Package Explorer") || view.getTitle().equals("Project Explorer")) { explorer = view; break; } } if (explorer == null) { throw new WidgetNotFoundException( "Could not find the 'Package Explorer' or 'Project Explorer' view."); } // Select the root of the project tree in the explorer view Widget explorerWidget = explorer.getWidget(); Tree explorerTree = bot.widget(widgetOfType(Tree.class), explorerWidget); return new SWTBotTree(explorerTree).getTreeItem(projectName).select(); }
/** * @param bot * @return */ public static boolean projectExplorerCleanUpAfterClass(SWTWorkbenchBot bot) { bot.saveAllEditors(); SWTBotTreeItem[] swtBotTreeItems = bot .viewByTitle(Properties.VIEW_PROJECT_EXPLORER).bot().tree() .getAllItems(); for (SWTBotTreeItem tmpSwtBotTreeItem : swtBotTreeItems) { tmpSwtBotTreeItem.contextMenu( Properties.CONTEXTMENU_ITEM_CLOSE_PROJECT).click(); tmpSwtBotTreeItem.contextMenu(Properties.CONTEXTMENU_ITEM_DELETE) .click(); bot.shell(Properties.SHELL_DELETE_RESOURCES).activate(); bot.activeShell().bot().checkBox().click(); bot.activeShell().bot().button(Properties.BUTTON_OK).click(); bot.closeAllShells(); } bot.resetWorkbench(); bot = null; return true; }
/** * @param bot */ public static void handleCreationWizard(SWTWorkbenchBot bot) { bot.activeShell().bot().button(Properties.BUTTON_NEXT).click(); bot.textWithLabel(TEXT_WITH_LABEL_ENDPOINT_NAME).setText(ENDPOINT_NAME); bot.activeShell().bot().link() .click(IMAGE_HYPER_LINK_CREATE_NEW_PROJECT); SWTBotShell shell = bot.shell(Properties.SHELL_EMPTY_STRING); shell.activate(); bot.button(Properties.BUTTON_NEXT).click(); bot.textWithLabel(Properties.TEXT_WITH_LABEL_PROJECT_NAME).setText( PropertiesESB.ARTIFACT_MY_ESB_CONFIG_PROJECT_FOR_ENDPOINT_TEST); bot.button(Properties.BUTTON_FINISH).click(); bot.textWithLabel(Properties.TEXT_WITH_LABEL_Address).setText( PropertiesESB.ARTIFACT_ENDPOINT_URL); bot.button(Properties.BUTTON_FINISH).click(); }
/** * @param matcherImageHyperLink * @param bot * @return */ public static boolean openWizard(Matcher matcherImageHyperLink, SWTWorkbenchBot bot) { @SuppressWarnings("unchecked") ImageHyperlink link = (ImageHyperlink) bot .widget(matcherImageHyperLink); link.getClass(); SWTBotImageHyperlink swtbotImageHyperLink = new SWTBotImageHyperlink( link); swtbotImageHyperLink.click(); if (swtbotImageHyperLink.isEnabled()) { return true; } return false; }
@BeforeClass public static void beforeClass() throws Exception { bot = new SWTWorkbenchBot(); try { bot.viewByTitle("Welcome").close(); } catch (WidgetNotFoundException e) { // OK, no Welcome view, that's fine :) } // Change the perspective via the Open Perspective dialog bot.menu("Window").menu("Open Perspective").menu("Other...").click(); SWTBotShell openPerspectiveShell = bot.shell("Open Perspective"); openPerspectiveShell.activate(); // select the dialog bot.table().select("Plug-in Development"); bot.button("OK").click(); // in Luna the Error Log is not shown by default in the Plug-in Development perspective // bot.viewByPartName("Error Log").close(); // in SwtBot 2.2.0 we must use viewByPartName instead of viewByTitle bot.viewByPartName("Problems").show(); }
@BeforeClass public static void beforeClass() throws Exception { SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; SWTBotPreferences.TIMEOUT = 10000; bot = new SWTWorkbenchBot(); try { bot.viewByTitle("Welcome").close(); } catch (Exception e) { e.printStackTrace(); } }
public static void importProjectFromZip(SWTWorkbenchBot bot, String path) { int timeout = 10000; bot.menu("File").menu("Import...").click(); bot.waitUntil(Conditions.shellIsActive("Import")); SWTBotShell shell = bot.shell("Import").activate(); shell.bot().tree().expandNode("General").select("Existing Projects into Workspace"); shell.bot().button("Next >").click(); shell.bot().radio("Select archive file:").click(); shell.bot().comboBox(1).setText(path); shell.bot().comboBox(1).pressShortcut(SWT.CR, SWT.LF); SWTBotButton finishButton = shell.bot().button("Finish"); ICondition buttonEnabled = new DefaultCondition() { @Override public boolean test() throws Exception { return finishButton.isEnabled(); } @Override public String getFailureMessage() { return "Finish button not enabled"; } }; shell.bot().waitUntil(buttonEnabled, timeout); finishButton.click(); bot.waitUntil(Conditions.shellCloses(shell), timeout); }
private static boolean flexDeployMenuVisible(IProject project) { SWTBotTreeItem selected = SwtBotProjectActions.selectProject( new SWTWorkbenchBot(), project.getName()); try { selected.contextMenu("Deploy to App Engine Flexible..."); return true; } catch (WidgetNotFoundException e) { return false; } }
/** * Close the Welcome/Intro view, if found. Usually required on the first launch. */ public static void closeWelcome(SWTWorkbenchBot bot) { SWTBotView activeView = bot.activeView(); if (activeView != null && activeView.getTitle().equals("Welcome")) { activeView.close(); } }
/** * Reimplementation of {@link SWTWorkbenchBot#resetWorkbench()} due to Eclipse bug 511729 on * Oxygen. */ public static void resetWorkbench(SWTWorkbenchBot bot) { closeAllShells(bot); bot.saveAllEditors(); bot.closeAllEditors(); bot.resetActivePerspective(); bot.defaultPerspective().activate(); bot.resetActivePerspective(); }
/** * Wait until the given tree has items, and return the first item. * * @throws TimeoutException if no items appear within the default timeout */ public static SWTBotTreeItem waitUntilTreeHasItems(SWTWorkbenchBot bot, final SWTBotTree tree) { bot.waitUntil(new DefaultCondition() { @Override public String getFailureMessage() { return "Tree items never appeared"; } @Override public boolean test() throws Exception { return tree.hasItems(); } }); return tree.getAllItems()[0]; }