List of usage examples for org.openqa.selenium WebElement clear
void clear();
From source file:com.vaadin.framework8.samples.SpringCrudIT.java
License:Apache License
@Test public void createContact() { doLogin();//from w ww . j a v a 2 s . co m List<WebElement> primaries = findElements(By.className("primary")); List<WebElement> newProduct = primaries.stream() .filter(element -> element.getText().endsWith("New product")).collect(Collectors.toList()); Assert.assertEquals(1, newProduct.size()); newProduct.get(0).click(); WebElement form = findElement(By.className("product-form")); List<WebElement> fields = form.findElements(By.className("v-textfield")); WebElement productName = fields.get(0); productName.clear(); productName.sendKeys("New item"); WebElement price = fields.get(1); price.clear(); price.sendKeys("1.0"); WebElement stock = fields.get(2); stock.clear(); stock.sendKeys("2"); WebElement combo = form.findElement(By.className("v-filterselect-input")); String availability = combo.getAttribute("value"); form.findElement(By.className("primary")).click(); Collection<Product> allProducts = dataService.getAllProducts(); $(GridElement.class).first().scrollToRow(allProducts.size()); List<WebElement> rows = getRows(); WebElement beforeLast = rows.get(rows.size() - 2); List<WebElement> columns = beforeLast.findElements(By.tagName("td")); Assert.assertFalse(hasText(columns.get(1), "New item")); WebElement last = rows.get(rows.size() - 1); columns = last.findElements(By.tagName("td")); Assert.assertTrue(hasText(columns.get(1), "New item")); Assert.assertTrue(hasText(columns.get(2), "1.0")); Assert.assertTrue(hasText(columns.get(3), availability.toUpperCase(Locale.ENGLISH))); Assert.assertTrue(hasText(columns.get(4), "2")); }
From source file:com.vaadin.framework8.samples.SpringCrudIT.java
License:Apache License
@Test public void changeProductNameToValid_bothButtonsAreEnabled() { doLogin();//from w w w. ja v a2 s.c o m getRows().get(0).findElement(By.tagName("td")).click(); WebElement form = findElement(By.className("product-form")); List<WebElement> fields = form.findElements(By.className("v-textfield")); WebElement productName = fields.get(0); productName.clear(); productName.sendKeys("Updated Product Name"); productName.sendKeys(Keys.TAB); List<WebElement> buttons = form.findElements(By.className("v-button")); Assert.assertFalse(isDisabled(buttons.get(0))); Assert.assertFalse(isDisabled(buttons.get(1))); }
From source file:com.vaadin.framework8.samples.SpringCrudIT.java
License:Apache License
@Test public void changeProductNameToInvalid_saveIsDisabledAndDiscardIsEnabled() { doLogin();/*from w ww. jav a 2s. com*/ getRows().get(0).findElement(By.tagName("td")).click(); WebElement form = findElement(By.className("product-form")); List<WebElement> fields = form.findElements(By.className("v-textfield")); WebElement productName = fields.get(0); productName.clear(); productName.sendKeys("a"); productName.sendKeys(Keys.TAB); List<WebElement> buttons = form.findElements(By.className("v-button")); Assert.assertTrue(isDisabled(buttons.get(0))); Assert.assertFalse(isDisabled(buttons.get(1))); }
From source file:com.vaadin.tests.components.datefield.LegacyDateFieldIsValidTest.java
License:Apache License
@Test public void testInvalidText() throws Exception { openTestURL();/*w ww .j a va 2s . c o m*/ waitForElementVisible(By.id("Log")); waitForElementVisible(By.className("v-datefield")); WebElement dateTextbox = $(DateFieldElement.class).first().findElement(By.className("v-textfield")); ButtonElement button = $(ButtonElement.class).first(); dateTextbox.sendKeys("01/01/01", Keys.TAB); assertLogText("1. valueChange: value: 01/01/01, is valid: true"); button.click(); assertLogText("2. buttonClick: value: 01/01/01, is valid: true"); dateTextbox.sendKeys("lala", Keys.TAB); assertLogText("3. valueChange: value: null, is valid: false"); button.click(); assertLogText("4. buttonClick: value: null, is valid: false"); dateTextbox.clear(); dateTextbox.sendKeys("02/02/02", Keys.TAB); assertLogText("5. valueChange: value: 02/02/02, is valid: true"); button.click(); assertLogText("6. buttonClick: value: 02/02/02, is valid: true"); }
From source file:com.vaadin.tests.components.grid.basicfeatures.client.GridEditorClientTest.java
License:Apache License
@Test public void testSave() { selectMenuPath(EDIT_ROW_100);//from w w w . java 2 s.c o m WebElement textField = getEditor().findElements(By.className("gwt-TextBox")).get(0); textField.clear(); textField.sendKeys("Changed"); WebElement saveButton = getEditor().findElement(By.className("v-grid-editor-save")); saveButton.click(); assertEquals("Changed", getGridElement().getCell(100, 0).getText()); }
From source file:com.vaadin.tests.components.grid.basicfeatures.client.GridEditorClientTest.java
License:Apache License
@Test public void testProgrammaticSave() { selectMenuPath(EDIT_ROW_100);/*from w w w . j ava2 s . c o m*/ WebElement textField = getEditor().findElements(By.className("gwt-TextBox")).get(0); textField.clear(); textField.sendKeys("Changed"); selectMenuPath("Component", "Editor", "Save"); assertEquals("Changed", getGridElement().getCell(100, 0).getText()); }
From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridEditorBufferedTest.java
License:Apache License
private void makeInvalidEdition() { selectMenuPath(EDIT_ITEM_5);/* w w w . j av a2s . co m*/ assertFalse(logContainsText("Exception occured, java.lang.IllegalStateException")); GridEditorElement editor = getGridElement().getEditor(); assertFalse("Field 7 should not have been marked with an error before error", editor.isFieldErrorMarked(7)); WebElement intField = editor.getField(7); intField.clear(); intField.sendKeys("banana phone"); }
From source file:com.vaadin.tutorial.addressbook.AddressbookIT.java
License:Apache License
@Test public void updateContact() { int index = 1; List<WebElement> rows = getRows(); rows.get(index).findElement(By.tagName("td")).click(); WebElement form = findElement(By.id("contactform")); WebElement firstName = form.findElement(By.className("firstName")); firstName.clear(); firstName.sendKeys("Updated Name"); $(DateFieldElement.class).first().setValue("1/1/00"); form.findElement(By.className("primary")).click(); Assert.assertFalse(isElementPresent(By.className("contactform"))); rows = getRows();/* www . ja v a 2 s.co m*/ WebElement firstNameColumn = rows.get(index).findElement(By.tagName("td")); hasText(firstNameColumn, "Updated Name"); hasText($(GridElement.class).first().getCell(index, 3), "1/1/00"); }
From source file:com.vaadin.tutorial.addressbook.AddressbookIT.java
License:Apache License
@Test public void validationError() { int index = 1; List<WebElement> rows = getRows(); rows.get(index).findElement(By.tagName("td")).click(); WebElement form = findElement(By.id("contactform")); WebElement phone = form.findElement(By.className("phone")); WebElement email = form.findElement(By.className("email")); phone.clear(); email.clear();//ww w. j a v a2 s . c o m waitForElementVisible(By.className("v-errorindicator")); email.sendKeys("test@test.com", Keys.ENTER); waitForElementNotPresent(By.className("v-errorindicator")); }
From source file:com.vaadin.tutorial.addressbook.AddressbookIT.java
License:Apache License
@Test public void cancelButtonDiscardsChanges() { String firstCellText = $(GridElement.class).first().getCell(0, 0).getText(); getRows().get(0).findElement(By.tagName("td")).click(); WebElement form = findElement(By.id("contactform")); WebElement firstName = form.findElement(By.className("firstName")); firstName.clear(); firstName.sendKeys("Updated Name"); ButtonElement cancelButton = $(ButtonElement.class).get(2); cancelButton.click();//from ww w.j av a2 s .c o m Assert.assertEquals($(GridElement.class).first().getCell(0, 0).getText(), firstCellText); }