public void updateKeyCustomProperty(SWTBotGefEditPart part, String key, String newkey) { GraphElement element = selectPart(part); selectTab(part, CUSTOM); SWTBotTable table = botView.bot().tableWithId(CustomProperties.PROJECT_PROPERTY_PAGE_WIDGET_ID, CustomProperties.CUSTOM_PROPERTY_LIST_WITH_BUTTON); bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { int row = table.indexOf(key, "PROPERTY"); if (row == -1) return true; table.click(row, 0); bot.sleep(1000); bot.text(key, 0).setText(newkey); bot.text(KeyStroke.getInstance(SWT.TAB)+"" , 0); return false; } @Override public String getFailureMessage() { return "key not set"; } },2 * 60 * 1000); }
public void updateValueCustomProperty(SWTBotGefEditPart part, String key, String oldvalue, String newValue) { GraphElement element = selectPart(part); selectTab(part, CUSTOM); SWTBotTable table = botView.bot().tableWithId(CustomProperties.PROJECT_PROPERTY_PAGE_WIDGET_ID, CustomProperties.CUSTOM_PROPERTY_LIST_WITH_BUTTON); bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { int row = table.indexOf(oldvalue, "VALUE"); if (row == -1) return true; table.click(row, 1); bot.sleep(1000); bot.text(oldvalue, 0).setText(newValue); bot.text(KeyStroke.getInstance(SWT.TAB)+"" , 0); return false; } @Override public String getFailureMessage() { return "value not set"; } },2 * 60 * 1000); }
public void deleteCustomProperty(SWTBotGefEditPart part, String key) { GraphElement element = selectPart(part); selectTab(part, CUSTOM); SWTBotTable table = botView.bot().tableWithId(CustomProperties.PROJECT_PROPERTY_PAGE_WIDGET_ID, CustomProperties.CUSTOM_PROPERTY_LIST_WITH_BUTTON); bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { int row = table.indexOf(key, "PROPERTY"); table.click(row, 0); table.contextMenu("Remove entry").click(); return table.indexOf(key, 0) == -1; } @Override public String getFailureMessage() { return "row not deleted"; } },2 * 60 * 1000); }
@Test public void testSelectBookmarksFile() throws Exception { // Given File file = createBookmarksFile(gdriveConnectionUser1, "bookmarks1", "any"); openDialog(shell -> createDialog(shell, gdriveConnectionUser1, Optional.of(gdriveConnectionUser1.getApplicationFolderId()))); // When SWTBotTable botTable = bot.table(); assertEquals(1, botTable.rowCount()); botTable.select(0); clickOkButton(); // Then assertEquals(file.getId(), dialog.getFile().getId()); }
@Test @Ignore("Currently fails when run with maven") public void testAddLinkAndSelectBookmarksFile() throws Exception { // Given File file = createBookmarksFile(gdriveConnectionUser2, "bookmarks from user2", "any"); shareWithAnyoneWithLink(gdriveConnectionUser2, file.getId()); openDialog(shell -> createDialog(shell, gdriveConnectionUser1, Optional.of(gdriveConnectionUser1.getApplicationFolderId()))); // When SWTBotTable botTable = bot.table(); assertEquals(0, botTable.rowCount()); addLink(file.getAlternateLink()); botTable.getTableItem(0).select(); clickOkButton(); // Then assertEquals(file.getId(), dialog.getFile().getId()); }
/** * Wait for table items. * * @param table * the table * @param timeout * the timeout */ @SuppressWarnings("PMD.ConfusingTernary") public static void waitForTableItems(final SWTBotTable table, final int timeout) { final long endTimeMillis = System.currentTimeMillis() + timeout; while (System.currentTimeMillis() < endTimeMillis) { if (table.getTableItem(0) != null) { return; } else { try { Thread.sleep(THREAD_SLEEP_TIME); } catch (InterruptedException e) { e.fillInStackTrace(); } } } }
private void addFourOrdersToOrdersOverview() { SWTBotView view = wbBot.partById(BaseSWTBotTest.PART_ID_ORDER_OVERVIEW); view.toolbarButton("Search Order").click(); SWTBotText text = bot.textWithLabel("&Order Number"); text.typeText("Order"); bot.buttonWithTooltip("Start Search").click(); // Select Item in Table SWTBotTable table = bot.table(); totalPersistedOrders = table.rowCount(); table.click(0, 5); bot.sleep(100); table.click(1, 5); bot.sleep(100); table.click(3, 5); bot.sleep(100); table.click(5, 5); bot.sleep(100); // click Finish bot.button("OK").click(); }
@Test public void testThatAllProjectsAreDeselectedWithDeselectAll() { openImportProjectWizardPage(); final SWTBotTable projectTable = bot.table(0); for (int i = 0; i < projectTable.rowCount(); i++) { projectTable.getTableItem(i).check(); } bot.button("Deselect All").click(); for (int i = 0; i < projectTable.rowCount(); i++) { final SWTBotTableItem oneProjectRow = projectTable.getTableItem(i); Assert.assertFalse(oneProjectRow.isChecked()); } }
public String getCustomProperty(SWTBotGefEditPart part, String key) { GraphElement element = selectPart(part); selectTab(part, CUSTOM); SWTBotTable table = botView.bot().tableWithId(CustomProperties.PROJECT_PROPERTY_PAGE_WIDGET_ID, CustomProperties.CUSTOM_PROPERTY_LIST_WITH_BUTTON); int row = table.indexOf(key, "PROPERTY"); return table.cell(row, "VALUE"); }
public void assertContext(SWTBotShell page, SummaryExecutionRow[] rows) { SWTBotTable table = bot.tableWithId( org.gw4e.eclipse.wizard.runasmanual.SummaryExecutionPage.GW4E_MANUAL_ELEMENT_ID, org.gw4e.eclipse.wizard.runasmanual.SummaryExecutionPage.GW4E_MANUAL_TABLE_VIEWER_SUMMARY_ID); int max = table.rowCount(); for (int i = 0; i < max; i++) { SWTBotTableItem item = table.getTableItem(i); String status = getStatus(item); String step = item.getText(1); String result = item.getText(2); String description = item.getText(4); String statusExpected = rows[i].getStatus() + ""; String stepExpected = rows[i].getStepname(); String resultExpected = rows[i].getResult(); String defaultResult = MessageUtil.getString("enter_a_result_if_verification_failed"); if (defaultResult.equalsIgnoreCase(resultExpected)) { resultExpected = ""; } String descriptionExpected = rows[i].getDescription(); org.junit.Assert.assertEquals("Invalid status", statusExpected, status); org.junit.Assert.assertEquals("Invalid step", stepExpected, step); org.junit.Assert.assertEquals("Invalid result", resultExpected, result); org.junit.Assert.assertEquals("Invalid description", descriptionExpected, description); } }
public void assertTargetElements(String... names) { SWTBotTable table = bot.tableWithId(GraphElementSelectionUIPage.GW4E_CONVERSION_WIDGET_ID, GraphElementSelectionUIPage.GW4E_CONVERSION_TARGET_TABLE_ID); for (String name : names) { int index = table.indexOf(name, 0); if (index == -1) org.junit.Assert.fail(name + " not found in the target column"); } }
public void assertSourceElements(String... names) { SWTBotTable table = bot.tableWithId(GraphElementSelectionUIPage.GW4E_CONVERSION_WIDGET_ID, GraphElementSelectionUIPage.GW4E_CONVERSION_SOURCE_TABLE_ID); for (String name : names) { int index = table.indexOf(name, 0); if (index == -1) org.junit.Assert.fail(name + " not found in the source column"); } }
public void selectAdditionalContext (String [] additionalsContext) { SWTBotTable table = bot.tableWithId(JUnitGW4ETestUIPage.GW4E_CONVERSION_WIDGET_ID,JUnitGW4ETestUIPage.GW4E_LAUNCH_TEST_CONFIGURATION_ADDITIONAL_CONTEXT); int count = table.rowCount(); for (String context : additionalsContext) { for (int i = 0; i < count; i++) { SWTBotTableItem item = table.getTableItem(i); int cols = table.columnCount(); for (int j = 0; j < cols; j++) { if (item.getText(j).equals(context)) { item.check(); }; } } } }
public void selectGenerators (String [] generators) { SWTBotTable table = bot.tableWithId(BuildPoliciesCheckboxTableViewer.GW4E_CONVERSION_WIDGET_ID, BuildPoliciesCheckboxTableViewer.GW4E_CONVERSION_TABLE_GENERATORS); int max = table.rowCount(); for (int i = 0; i < max; i++) { SWTBotTableItem item = table.getTableItem(i); for (String generator : generators) { if (generator.equalsIgnoreCase(item.getText())) { item.check(); } } } }
public boolean hasGenerator (String value) { SWTBotTable table = getBuildPoliciesTable(); int max = table.rowCount(); for (int i = 0; i < max; i++) { SWTBotTableItem item = table.getTableItem(i); if (value.equalsIgnoreCase(item.getText())) { return true; } } return false; }
boolean tableContainValues(String [] thevalues ) { SWTBotTable table = getTable(); for (int i = 0; i < thevalues.length; i++) { if (!table.containsItem(thevalues[i]) ) return false ; } return true; }
void addRowValue(final String stringtoadd) { SWTBotTable table = getTable(); bot.waitUntil(waitForTable()); int currentCount = table.rowCount(); SWTBotButton addButton = getAddButton(); addButton.click(); waitForRowAdded(table, currentCount + 1); int row = 0; editRowWithValue (table,MessageUtil.getString("enteranewvalue"), stringtoadd); leaveEditingCellClickingOnAnotherCell(table, row + 1); waitForExpectedValueAtRowCol(table,stringtoadd); }
void removeRow( String stringtoremove) { SWTBotTable table = getTable(); bot.waitUntil(waitForTable()); selectRowWithValue(table,stringtoremove); waitForExpectedValueAtRowCol(table,stringtoremove); int currentCount = table.rowCount(); SWTBotButton removeButton = getRemoveButton(); removeButton.click(); waitForRowAdded(table, currentCount - 1); waitForNotExpectedValueAtRowCol(table,stringtoremove); }
private ICondition waitForTable() { return new DefaultCondition() { public boolean test() throws Exception { SWTBotTable table = getTable(); return table != null; } public String getFailureMessage() { return "Table : Authorized Folder For Graph Definition has not been found"; } }; }
private void waitForRowAdded(final SWTBotTable table, final int expectedCount) { ICondition condition = new DefaultCondition() { public boolean test() throws Exception { return table.rowCount() == expectedCount; } public String getFailureMessage() { return "Table " + id + " has not " + expectedCount + " row(s). It has " + expectedCount + " row(s)"; } }; bot.waitUntil(condition); }
private void waitForExpectedValueAtRowCol(final SWTBotTable table, final String expectedValue) { ICondition condition = new DefaultCondition() { public boolean test() throws Exception { return table.containsItem(expectedValue); } public String getFailureMessage() { return "Table '"+ id + " does not contains " + expectedValue; } }; bot.waitUntil(condition); }
private void waitForNotExpectedValueAtRowCol(final SWTBotTable table, final String expectedValue) { ICondition condition = new DefaultCondition() { public boolean test() throws Exception { return !table.containsItem(expectedValue); } public String getFailureMessage() { return "Table '"+ id + " does not contains " + expectedValue; } }; bot.waitUntil(condition); }
public void setSelectionFileStatus (String path,boolean checked) { SWTBotTable table= getTable (); int max=table.rowCount(); for (int i = 0; i < max; i++) { SWTBotTableItem tableItem = table.getTableItem(i); ModelData d = (ModelData) tableItem.widget.getData(); if (d.getName().equalsIgnoreCase(path)) { tableItem.widget.setChecked(checked); } } }
public void selectPathGenerator (String file,String path) { SWTBotTable table= getTable (); int max=table.rowCount(); for (int i = 0; i < max; i++) { SWTBotTableItem tableItem = table.getTableItem(i); ModelData d = (ModelData) tableItem.widget.getData(); if (d.getName().equalsIgnoreCase(file)) { selectComboPathGenerator(tableItem,path); } } }
/** * Click on all table cells in column {@code col} with the contents {@code value}. Selection * should be the last cell clicked upon. */ public static void clickOnTableCellValue(SWTBotTable table, int col, String value) { String column = table.columns().get(col); for (int row = 0; row < table.rowCount(); row++) { String cellValue = table.cell(row, column); if (cellValue.equals(value)) { table.click(row, col); break; } } }
/** * Returns items from a table. * * @param bot * to work with, must not be {@code null} * @param table * to look for items in, must not be {@code null} * @return list of table items, never {@code null} */ public static List<SWTBotTableItem> tableItems(final SWTWorkbenchBot bot, final SWTBotTable table) { Assert.isNotNull(bot, ARGUMENT_BOT); Assert.isNotNull(table, ARGUMENT_TABLE); waitForTableItem(bot, table); List<SWTBotTableItem> items = null; for (int i = 0; i < table.rowCount(); i++) { items = new ArrayList<SWTBotTableItem>(Arrays.asList(table.getTableItem(i))); } return items; }
/** * * @param table * @param rowindex */ public void selectOrderAndGenerateDocu(final int rowindex) { SWTBotTable table = bot.table(); table.click(rowindex, 5); bot.sleep(100); scenariooWriterHelper.writeStep("order_" + rowindex + "_selected", PageName.SEARCH_DIALOG, screenshot()); }
private void createOrderTemp() { // add new Order, As we don't want to interfere with other test cases bot.toolbarButtonWithTooltip("Create Order").click(); SWTBotText text = bot.textWithLabel("&Order Number"); text.typeText(ORDER_NUMBER_TEMP); bot.button("Next >").click(); bot.buttonWithTooltip("Add Position").click(); // Select Item in Table SWTBotTable table = bot.table(); // Position Amount table.click(0, 4); bot.sleep(100); bot.text(1).setText("2"); // Select Item bot.table().click(0, 2); bot.sleep(100); bot.ccomboBox(0).setSelection(13); // loose Focus table.click(0, 3); bot.sleep(100); // click Finish bot.button("Finish").click(); bot.sleep(500); LOGGER.info("\n" + "-----------------------------------------------------------------\n" + "create temp order rule : order " + ORDER_NUMBER_TEMP + " created.\n" + "-----------------------------------------------------------------\n\n"); }
/** * @param table */ private void selectItemForFirstRowAndGenerateDocu(final SWTBotTable table) { bot.table().click(0, 2); bot.sleep(100); bot.ccomboBox(0).setSelection(6); table.click(0, 3); // Input is accepted after focus lost bot.sleep(100); scenariooWriterHelper.writeStep("item_selected", PageName.ORDER_NEW_2, screenshot()); }
/** * @return */ private SWTBotTable enterAmountForFirstRowAndGenerateDocu() { // Select Item in Table SWTBotTable table = bot.table(); table.click(0, 4); bot.text(1).setText("3"); bot.sleep(100); table.click(0, 3); // Input is accepted after focus lost bot.sleep(100); scenariooWriterHelper.writeStep("position_count_entered", PageName.ORDER_NEW_2, screenshot()); return table; }
public static void clickOnTableCellValue(SWTBotTable table, int col, String value) { String column = table.columns().get(col); for (int row = 0; row < table.rowCount(); row++) { String cellValue = table.cell(row, column); if (cellValue.equals(value)) { table.click(row, col); break; } } }
public void importCodenvyProject(String workspaceName, String projectName) { final SWTBotShell shell = openImportProjectWizardPage(); final SWTBotCombo workspaceCombo = bot.comboBox(0); workspaceCombo.setSelection(workspaceName); final SWTBotTable projectTable = bot.table(0); bot.waitUntil(new TableHasRows(projectTable)); for (int i = 0; i < projectTable.rowCount(); i++) { if (projectTable.cell(i, 0).equals(projectName)) { projectTable.getTableItem(i).check(); } } bot.table(0).getTableItem(projectName).check(); bot.button("Finish").click(); bot.waitUntil(shellCloses(shell)); try { Job.getJobManager().join(CodenvyPlugin.FAMILY_CODENVY, null); } catch (OperationCanceledException | InterruptedException e) { throw new RuntimeException(e); } }
@Test public void testThatProjectTableContainsAllWorkspaceProjects() { openImportProjectWizardPage(); final SWTBotTable projectTable = bot.table(0); Assert.assertTrue(projectTable.rowCount() == 4); Assert.assertEquals(MOCK_PROJECT_NAME, projectTable.cell(0, 0)); Assert.assertEquals(MOCK_PROJECT_TYPE_NAME, projectTable.cell(0, 1)); Assert.assertEquals(MOCK_PROJECT_DESCRIPTION, projectTable.cell(0, 2)); }
@Test public void testThatAllProjectsAreSelectedWithSelectAll() { openImportProjectWizardPage(); final SWTBotTable projectTable = bot.table(0); bot.button("Select All").click(); for (int i = 0; i < projectTable.rowCount(); i++) { final SWTBotTableItem oneProjectRow = projectTable.getTableItem(i); Assert.assertTrue(oneProjectRow.isChecked()); } }
@Test public void testThatAlreadyImportedProjectIsGrayedInProjectTable() throws CoreException { importCodenvyProject(MOCK_WORKSPACE_NAME, MOCK_PROJECT_NAME); openImportProjectWizardPage(); final SWTBotTable projectTable = bot.table(0); for (int i = 0; i < projectTable.rowCount(); i++) { final SWTBotTableItem oneProjectRow = projectTable.getTableItem(i); Assert.assertTrue(oneProjectRow.isGrayed() == MOCK_PROJECT_NAME.equals(projectTable.cell(i, 0))); } }
public void executeQuickFixForErrorMessage(String expectedErrorMessageInProblemView, String quickfixmessage, ICondition[] conditions) throws CoreException { print (); bot.waitUntil(new ErrorIsInProblemView(this, expectedErrorMessageInProblemView)); SWTBotTreeItem item = findErrorItemWithText(expectedErrorMessageInProblemView); item.setFocus(); item.click(); bot.waitUntil(new IsItemSelectedInErrors(this, item)); ICondition condition = new DefaultCondition () { @Override public boolean test() throws Exception { item.contextMenu().menu("Quick Fix").click(); try { bot.waitUntil(Conditions.shellIsActive("Quick Fix"), 2 * 1000 ); } catch (Exception e) { return false; } return true; } @Override public String getFailureMessage() { return "Unable to open the Quick fix"; } }; bot.waitUntil(condition, 15 * 1000); SWTBotShell shell = bot.shell("Quick Fix"); SWTBotTable table = shell.bot().tableWithLabel("Select a fix:"); SWTBotTableItem thequickFixItem = table.getTableItem(quickfixmessage); thequickFixItem.click(); thequickFixItem.select(); SWTBotButton button = shell.bot().button("Finish"); button.click(); bot.waitUntil(Conditions.shellCloses(shell),TIMEOUT); bot.saveAllEditors(); GW4EProject.fullBuild(); if (conditions != null) { for (int i = 0; i < conditions.length; i++) { bot.waitUntil(conditions[i], TIMEOUT); } } }
public int getRowCount () { SWTBotTable table = bot.tableWithId(PerformanceView.PERFORMANCE_VIEW_WIDGET_ID, PerformanceView.PERFORMANCE_VIEW_TABLE); return table.rowCount(); }
public void moveSourceToTarget(String value) { SWTBotTable table = bot.tableWithId(GraphElementSelectionUIPage.GW4E_CONVERSION_WIDGET_ID, GraphElementSelectionUIPage.GW4E_CONVERSION_SOURCE_TABLE_ID); table.select(value); bot.button("Add").click(); }
public void moveTargetToSource(String value) { SWTBotTable table = bot.tableWithId(GraphElementSelectionUIPage.GW4E_CONVERSION_WIDGET_ID, GraphElementSelectionUIPage.GW4E_CONVERSION_TARGET_TABLE_ID); table.select(value); bot.button("Remove").click(); }
public void moveUp(String value) { SWTBotTable table = bot.tableWithId(GraphElementSelectionUIPage.GW4E_CONVERSION_WIDGET_ID, GraphElementSelectionUIPage.GW4E_CONVERSION_TARGET_TABLE_ID); table.select(value); bot.button("Up").click(); }