List of usage examples for org.openqa.selenium WebElement clear
void clear();
From source file:influent.selenium.tests.TransactionsSearchResultsTest.java
License:MIT License
/** * Runs a query and checks that all of the results are as expected * @param query// ww w .j a v a 2 s. c om * @param expectedNumResults * @param expectedResults * An array of expected search results. Each search result should be in the form:<br> * { int index, String date, String to, String from } */ private void validateSearchResults(String query, int expectedNumResults, Object expectedResults[][]) { List<WebElement> elements = driver.findElements(By.cssSelector("#influent-filterbar-search-input")); //sort the expected results so we don't do extra work jumping between pages Arrays.sort(expectedResults, new Comparator<Object[]>() { @Override public int compare(Object[] o1, Object[] o2) { return ((Integer) o1[0]).compareTo((Integer) o2[0]); } }); WebElement element = SeleniumUtils.getDisplayedElement(elements); if (element == null) { throw new AssertionError("Couldn't find: influent-filterbar-search-input element"); } element.clear(); //clear the text from the input box first element.sendKeys(query); //pass in the query elements = driver.findElements(By.cssSelector(".btn-default")); element = SeleniumUtils.getDisplayedElement(elements); if (element == null) { throw new AssertionError("Couldn't find: btn-default element"); } element.click(); element = (new WebDriverWait(driver, 120)) .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(".simpleSearchSummary"))); assertEquals("Showing 1 - " + Math.min(expectedNumResults, MAX_NUM_RESULTS_PER_PAGE) + " of " + expectedNumResults + " results", element.getText()); for (Object[] expectedResult : expectedResults) { //get the search result index this expected result refers to int resultNum = (Integer) expectedResult[0]; //find the search result element WebElement searchResult = getSearchResult(resultNum); Assert.assertNotNull("Couldn't find search result " + resultNum + " for query: '" + query + "'", searchResult); //check that the results are as expected assertSearchResult((String) expectedResult[1], (String) expectedResult[2], (String) expectedResult[3], searchResult); } }
From source file:info.magnolia.integrationtests.uitest.AbstractMagnoliaUITest.java
License:Open Source License
private void clearAndSetTextForInputElement(WebElement input, String text) { input.click(); input.clear(); input.sendKeys(text); }
From source file:info.magnolia.integrationtests.uitest.AbstractMagnoliaUITest.java
License:Open Source License
protected void addCompositeTextFieldValue(String fieldLabel, String value) { WebElement input = getCompositeTextFieldValue(fieldLabel); input.clear(); input.sendKeys(value);//from www . j a v a 2s .c o m }
From source file:info.magnolia.integrationtests.uitest.AbstractMagnoliaUITest.java
License:Open Source License
protected void setMultiFieldInnerTextValueAt(String fieldLabel, int mainFieldPosition, int subFieldPosition, String value) {/*from ww w .ja v a 2 s.c o m*/ WebElement input = getMultiFieldInnerText(fieldLabel, mainFieldPosition, subFieldPosition); input.clear(); input.sendKeys(value); }
From source file:info.magnolia.integrationtests.uitest.AbstractMagnoliaUITest.java
License:Open Source License
protected void setMultiFieldComponentTextValueAt(String fieldLabel, int mainFieldPosition, String value) { WebElement input = getMultiFieldComponentTextElement(fieldLabel, mainFieldPosition); input.clear(); input.sendKeys(value);/* w w w. j a va 2 s. c om*/ }
From source file:info.magnolia.integrationtests.uitest.AbstractMagnoliaUITest.java
License:Open Source License
protected void setMultiFieldElementValueAt(String multiFieldLabel, int position, String value) { WebElement input = getFromMultiFieldElementValueAt(multiFieldLabel, position); input.clear(); input.sendKeys(value);//from w w w.j a va 2 s . com }
From source file:info.magnolia.integrationtests.uitest.AbstractMagnoliaUITest.java
License:Open Source License
protected void setMultiFieldComplexeElementValueAt(String multiFieldLabel, int multiFieldposition, int compositeFieldposition, String value) { WebElement input = getFromMultiFieldComplexeElementValueAt(multiFieldLabel, multiFieldposition, compositeFieldposition);//from www.j av a2 s . co m input.clear(); input.sendKeys(value); }
From source file:info.magnolia.integrationtests.uitest.CategoriesAppUITest.java
License:Open Source License
@Test public void verifyBasicCreateReadUpdateDelete() { // GIVEN/* ww w . j a v a2s.co m*/ final String testName = "TestCategory"; getAppIcon("Categories").click(); waitUntil(appIsLoaded()); assertAppOpen("Categories"); getActionBarItem("Add folder").click(); waitUntil(elementToBeClickable(getTreeTableItem("untitled"))); getActionBarItem("Add category").click(); waitUntil(appIsLoaded()); getFormTextField("Category name").sendKeys(testName); getFormTextField("Display name").sendKeys(StringUtils.capitalize(testName)); getFormTextField("Category name").click(); // WHEN getDialogButton("v-button-commit").click(); waitUntil(appIsLoaded()); // we expect preloader to show up when heading back to browser subapp // THEN expandTreeAndSelectAnElement(testName, "untitled"); assertTrue(isExisting(getTreeTableItem(testName))); // GIVEN - rename final String renamedName = "RenamedFrom" + testName; getActionBarItem("Edit category").click(); waitUntil(appIsLoaded()); WebElement categoryNameField = getFormTextField("Category name"); categoryNameField.clear(); categoryNameField.sendKeys(renamedName); getFormTextField("Display name").click(); // WHEN getDialogButton("v-button-commit").click(); waitUntil(appIsLoaded()); // we expect preloader to show up when heading back to browser subapp // THEN assertTrue(isExisting(getTreeTableItem(renamedName))); // GIVEN - delete if (!isTreeTableItemSelected("untitled")) { getTreeTableItem("untitled").click(); } getActionBarItem("Delete folder").click(); getDialogButtonWithCaption("Yes, delete").click(); waitUntil(elementIsGone(byDialogButtonWithCaption("Yes, delete"))); // WHEN getActionBarItem("Publish deletion").click(); // THEN waitUntil(15, elementIsGone( String.format("//*[contains(@class, 'v-table-cell-wrapper') and text() = '%s']", "untitled"))); }
From source file:info.magnolia.integrationtests.uitest.ConfigurationAppUITest.java
License:Open Source License
private void renameTableItemByDoubleClick(String oldName, String newName) { WebElement propertyElement = getTreeTableItem(oldName); doubleClick(propertyElement);//from ww w . j a v a 2 s . c om WebElement textField = getElementByXpath( "//*[contains(@class, 'v-table-cell-wrapper')]/input[@type = 'text']", newName); textField.clear(); textField.sendKeys(newName); simulateKeyPress(Keys.RETURN); }
From source file:info.magnolia.integrationtests.uitest.RssAggregatorAppUITest.java
License:Open Source License
@Test public void verifyBasicCreateReadUpdateDelete() { // GIVEN//from w w w .j ava 2s . c o m final String testName = "TestRss"; getAppIcon("Feeds").click(); waitUntil(appIsLoaded()); assertAppOpen("Feeds"); getEnabledActionBarItem("Add folder").click(); delay(1, "Wait until folder is created"); getEnabledActionBarItem("Add feed").click(); getFormTextField("Name").sendKeys(testName); getFormTextField("Title").sendKeys("TestTitle"); // work around the prob that sometimes newly entered text is not considered for validation delay("Sometimes it's also timing so let's wait a moment"); getFormTextField("Name").click(); // WHEN getDialogButton("v-button-commit").click(); waitUntil(appIsLoaded()); // we expect preloader to show up when heading back to browser subapp // THEN expandTreeAndSelectAnElement(testName, "untitled"); assertTrue(isExisting(getTreeTableItem(testName))); // GIVEN - rename final String renamedName = "RenamedFrom" + testName; getEnabledActionBarItem("Edit feed").click(); WebElement categoryNameField = getFormTextField("Name"); categoryNameField.clear(); categoryNameField.sendKeys(renamedName); // work around the prob that sometimes newly entered text is not considered for validation delay("Sometimes it's also timing so let's wait a moment"); getFormTextField("Title").click(); // WHEN - rename getDialogButton("v-button-commit").click(); waitUntil(appIsLoaded()); // we expect preloader to show up when heading back to browser subapp // THEN assertTrue(isExisting(getTreeTableItem(renamedName))); // GIVEN - delete getTreeTableItem("untitled").click(); getEnabledActionBarItem("Delete folder").click(); getDialogButtonWithCaption("Yes, delete").click(); waitUntil(elementIsGone(byDialogButtonWithCaption("Yes, delete"))); // WHEN getEnabledActionBarItem("Publish deletion").click(); // THEN waitUntil(elementIsGone("//*[contains(@class, 'v-table-cell-wrapper') and text() = 'untitled']")); }