List of usage examples for org.openqa.selenium Keys ENTER
Keys ENTER
To view the source code for org.openqa.selenium Keys ENTER.
Click Source Link
From source file:org.xmlium.test.web.commons.xml.XMLTestSteps.java
License:LGPL
protected void checkSendKeys(Element e, WebElement element) { if (e.getSendKeys() != null) { Boolean unformat = false; if (e.getFinds().getFind() != null) { unformat = e.getFinds().getFind().isUnformat(); } else {//ww w .j a v a 2 s. c o m if (e.getFinds().getWaitFor() != null) { unformat = e.getFinds().getWaitFor().isUnformat(); } } String value = checkValue(unformatValue(unformat, e.getSendKeys().getValue())); if (e.isCheckNullElement()) { if (element != null) { logger.debug(e.getSendKeys()); //Actions actions = new Actions(getSuite().getDriver()); if (e.getSendKeys().isRemoveOld() != null && e.getSendKeys().isRemoveOld()) { element.clear(); } element.sendKeys(value); if (e.getSendKeys().isPressEnter() != null && e.getSendKeys().isPressEnter()) { element.sendKeys(Keys.ENTER); } } } else { if (element != null) { logger.debug(e.getSendKeys()); //Actions actions = new Actions(getSuite().getDriver()); if (e.getSendKeys().isRemoveOld() != null && e.getSendKeys().isRemoveOld()) { element.clear(); } element.sendKeys(value); if (e.getSendKeys().isPressEnter() != null && e.getSendKeys().isPressEnter()) { element.sendKeys(Keys.ENTER); } } } } }
From source file:org.xmlium.test.web.commons.xml.XMLTestSteps.java
License:LGPL
protected void checkSetValue(Element e, WebElement element) throws Exception { if (e.getSetValue() != null && e.getSetValue().getKeys() != null) { BigDecimal operand1 = null; BigDecimal operand2 = null; String operation = null;//from ww w. j a v a2 s . c om Boolean unformat = false; if (e.getFinds().getFind() != null) { unformat = e.getFinds().getFind().isUnformat(); } else { if (e.getFinds().getWaitFor() != null) { unformat = e.getFinds().getWaitFor().isUnformat(); } } Values values = e.getSetValue().getKeys(); List<String> keys = values.getKey(); if (keys == null) { throw new RuntimeException(e.toString() + "\n no values " + e + "!"); } String strValueExpression = unformatValue(unformat, e.getSetValue().getValueExpression()); if (strValueExpression == null || strValueExpression.isEmpty()) { throw new RuntimeException(e.toString() + " valueExpressionis null or empty!"); } String oldValue1 = null; String oldValue2 = null; if (keys.size() == 2) { oldValue1 = elementValuesMap.get(unformatValue(unformat, values.getKey().get(0))); oldValue2 = elementValuesMap.get(unformatValue(unformat, values.getKey().get(1))); if (oldValue1 == null) { throw new RuntimeException( e.toString() + "\n no value for key=" + values.getKey().get(0) + "!"); } if (oldValue2 == null) { throw new RuntimeException( e.toString() + "\n no value for key=" + values.getKey().get(1) + "!"); } } else if (keys.size() == 1) { oldValue1 = elementValuesMap.get(unformatValue(unformat, values.getKey().get(0))); if (oldValue1 == null) { throw new RuntimeException(e.toString() + "\n no value for key=" + unformatValue(unformat, values.getKey().get(0)) + "!"); } } if (oldValue1 != null && oldValue2 != null) { Matcher valueMatcher = valueExpressionStringPattern3.matcher(strValueExpression); if (valueMatcher.matches()) { String value1 = valueMatcher.group(1); // String value2 = valueMatcher.group(3); if (value1.equals("${0}")) { try { operand1 = (BigDecimal) getSuite().getCurrencyFormat().parse(oldValue1); operand2 = (BigDecimal) getSuite().getCurrencyFormat().parse(oldValue2); } catch (ParseException e2) { logger.error(e2.getMessage(), e2); } } else { try { operand2 = (BigDecimal) getSuite().getCurrencyFormat().parse(oldValue1); operand1 = (BigDecimal) getSuite().getCurrencyFormat().parse(oldValue2); } catch (ParseException e2) { logger.error(e2.getMessage(), e2); } } operation = valueMatcher.group(2); logger.debug("oldValue1=" + oldValue1); logger.debug("oldValue2=" + oldValue2); logger.debug("operand1=" + operand1); logger.debug("operand2=" + operand2); logger.debug("operation=" + operation); } else { throw new UnsupportedOperationException("not supported yet!"); } } else { Matcher valueMatcher1 = valueExpressionStringPattern1.matcher(strValueExpression); Matcher valueMatcher2 = valueExpressionStringPattern2.matcher(strValueExpression); if (valueMatcher1.matches()) { String newValue = valueMatcher1.group(1); operation = valueMatcher1.group(2); logger.debug("newValue=" + newValue); logger.debug("operation=" + operation); try { operand1 = (BigDecimal) getSuite().getCurrencyFormat().parse(newValue); operand2 = (BigDecimal) getSuite().getCurrencyFormat().parse(oldValue1); } catch (ParseException e2) { logger.error(e2.getMessage(), e2); } } else if (valueMatcher2.matches()) { String newValue = valueMatcher2.group(3); operation = valueMatcher2.group(2); logger.debug("newValue=" + newValue); logger.debug("operation=" + operation); try { operand2 = (BigDecimal) getSuite().getCurrencyFormat().parse(newValue); operand1 = (BigDecimal) getSuite().getCurrencyFormat().parse(oldValue1); } catch (ParseException e2) { logger.error(e2.getMessage(), e2); } } else { throw new UnsupportedOperationException("not supported yet!"); } } if (operand1 != null && operand2 != null && operation != null && !operation.isEmpty()) { BigDecimal value = computeValue(operation, operand1, operand2); try { element.sendKeys(Keys.chord(Keys.CONTROL, "a")); element.sendKeys(getSuite().getCurrencyFormat().format(value), Keys.ENTER); } catch (Exception e1) { logger.error(e, e1); throw e1; } } else { throw new RuntimeException(e.toString() + "operand1=" + operand1 + ", operand2=" + operand2 + ", operation=" + operation); } } else if (e.getSetValue() != null && e.getSetValue().getKeys() == null) { throw new RuntimeException(e.toString() + "\n key==null!"); } }
From source file:org.xwiki.extension.test.po.SimpleSearchPane.java
License:Open Source License
/** * Searches for the extensions matching the given keywords. * /*from w w w .ja va 2 s. c o m*/ * @param keywords the keywords to search for * @return the search results pane */ public SearchResultsPane search(CharSequence keywords) { searchInput.clear(); searchInput.sendKeys(keywords, Keys.ENTER); return new SearchResultsPane(); }
From source file:org.xwiki.platform.notifications.test.po.NotificationsTrayPage.java
License:Open Source License
/** * Click the button Clear All in the notification tray. *//*from w w w . j av a 2s . c o m*/ public void clearAllNotifications() { if (!this.areNotificationsAvailable()) { return; } else { this.showNotificationTray(); this.clearAllLink.click(); this.sendKeys(Keys.ENTER); this.waitForNotificationSuccessMessage("Notifications have been cleared"); } }
From source file:org.xwiki.test.selenium.framework.AlbatrossSkinExecutor.java
License:Open Source License
public void typeEnterInWysiwyg() { sendKeysToTinyMCE(Keys.ENTER); }
From source file:org.xwiki.test.selenium.framework.AlbatrossSkinExecutor.java
License:Open Source License
public void typeShiftEnterInWysiwyg() { sendKeysToTinyMCE(Keys.chord(Keys.SHIFT, Keys.ENTER)); }
From source file:org.xwiki.test.ui.appwithinminutes.UserClassFieldTest.java
License:Open Source License
@Test public void testSingleSelection() { UserPicker userPicker = new UserClassFieldEditPane(editor.addField("User").getName()).getUserPicker(); // Use the keyboard. userPicker.sendKeys("mor").waitForSuggestions().sendKeys(Keys.ARROW_DOWN, Keys.ARROW_DOWN, Keys.ENTER); List<UserElement> selectedUsers = userPicker.waitForSuggestionsToFadeOut().getAcceptedSuggestions(); Assert.assertEquals(1, selectedUsers.size()); assertUserElement(selectedUsers.get(0), "Thomas Mortagne"); Assert.assertEquals("", userPicker.getValue()); // The link to clear the list of selected users should be displayed if at least 2 users are selected. Assert.assertFalse(userPicker.getClearSelectionLink().isDisplayed()); // Use the mouse. Since we have single selection by default, the previously selected user should be replaced. userPicker.sendKeys("mor").waitForSuggestions().select("Enygma2002"); selectedUsers = userPicker.waitForSuggestionsToFadeOut().getAcceptedSuggestions(); Assert.assertEquals(1, selectedUsers.size()); assertUserElement(selectedUsers.get(0), "Eduard Moraru", "Enygma2002"); Assert.assertEquals("", userPicker.getValue()); Assert.assertFalse(userPicker.getClearSelectionLink().isDisplayed()); // Delete the selected user. selectedUsers.get(0).delete();/* www. j ava 2 s.c o m*/ Assert.assertEquals(0, userPicker.getAcceptedSuggestions().size()); Assert.assertFalse(userPicker.getClearSelectionLink().isDisplayed()); // When there is only one suggestion, Enter key should select it. userPicker.sendKeys("admin").waitForSuggestions().sendKeys(Keys.ENTER); selectedUsers = userPicker.waitForSuggestionsToFadeOut().getAcceptedSuggestions(); Assert.assertEquals(1, selectedUsers.size()); assertUserElement(selectedUsers.get(0), "Administrator", "Admin", "noavatar.png"); Assert.assertEquals("", userPicker.getValue()); Assert.assertFalse(userPicker.getClearSelectionLink().isDisplayed()); }
From source file:org.xwiki.test.ui.appwithinminutes.UserClassFieldTest.java
License:Open Source License
@Test public void testMultipleSelection() { UserClassFieldEditPane userField = new UserClassFieldEditPane(editor.addField("User").getName()); userField.openConfigPanel();/*from w w w . j a va 2s .c om*/ userField.setMultipleSelect(true); userField.closeConfigPanel(); UserPicker userPicker = userField.getUserPicker(); // Select 2 users. userPicker.sendKeys("tmortagne").waitForSuggestions().sendKeys(Keys.ENTER).waitForSuggestionsToFadeOut(); Assert.assertFalse(userPicker.getClearSelectionLink().isDisplayed()); userPicker.sendKeys("2002").waitForSuggestions().select("Enygma").waitForSuggestionsToFadeOut(); Assert.assertTrue(userPicker.getClearSelectionLink().isDisplayed()); List<UserElement> selectedUsers = userPicker.getAcceptedSuggestions(); Assert.assertEquals(2, selectedUsers.size()); assertUserElement(selectedUsers.get(0), "Thomas Mortagne"); assertUserElement(selectedUsers.get(1), "Eduard Moraru", "Enygma2002"); Assert.assertEquals("", userPicker.getValue()); // Delete the first selected user. selectedUsers.get(0).delete(); Assert.assertFalse(userPicker.getClearSelectionLink().isDisplayed()); // Select another user. userPicker.sendKeys("admin").waitForSuggestions().sendKeys(Keys.ENTER).waitForSuggestionsToFadeOut(); selectedUsers = userPicker.getAcceptedSuggestions(); Assert.assertEquals(2, selectedUsers.size()); assertUserElement(selectedUsers.get(0), "Eduard Moraru", "Enygma2002"); assertUserElement(selectedUsers.get(1), "Administrator", "Admin", "noavatar.png"); Assert.assertEquals("", userPicker.getValue()); // Change the order of the selected users. selectedUsers.get(1).moveBefore(selectedUsers.get(0)); assertUserElement(userPicker.getAcceptedSuggestions().get(0), "Administrator", "Admin", "noavatar.png"); // Clear the list of selected users. userPicker.getClearSelectionLink().click(); Assert.assertFalse(userPicker.getClearSelectionLink().isDisplayed()); Assert.assertEquals(0, userPicker.getAcceptedSuggestions().size()); }
From source file:org.xwiki.test.ui.appwithinminutes.UserClassFieldTest.java
License:Open Source License
@Test public void testSaveAndInitialSelection() { UserPicker userPicker = new UserClassFieldEditPane(editor.addField("User").getName()).getUserPicker(); userPicker.sendKeys("thomas").waitForSuggestions().sendKeys(Keys.ENTER); editor.clickSaveAndView().edit();/*from w w w . ja va2 s . co m*/ UserClassFieldEditPane userField = new UserClassFieldEditPane("user1"); userPicker = userField.getUserPicker().waitToLoad(); List<UserElement> selectedUsers = userPicker.getAcceptedSuggestions(); Assert.assertEquals(1, selectedUsers.size()); assertUserElement(selectedUsers.get(0), "Thomas Mortagne"); Assert.assertEquals("", userPicker.getValue()); // Enable multiple selection. userField.openConfigPanel(); userField.setMultipleSelect(true); userField.closeConfigPanel(); // Re-take the user picker because the display has been reloaded. userPicker = userField.getUserPicker(); // Select one more user. userPicker.waitToLoad().sendKeys("admin").waitForSuggestions().sendKeys(Keys.ENTER); editor.clickSaveAndContinue(); editor.clickCancel().edit(); userPicker = new UserClassFieldEditPane("user1").getUserPicker().waitToLoad(); selectedUsers = userPicker.getAcceptedSuggestions(); Assert.assertEquals(2, selectedUsers.size()); assertUserElement(selectedUsers.get(0), "Thomas Mortagne"); assertUserElement(selectedUsers.get(1), "Administrator", "Admin", "noavatar.png"); Assert.assertEquals("", userPicker.getValue()); // We should be able to input free text also. userPicker.sendKeys("foobar").waitForSuggestions().sendKeys(Keys.ESCAPE).waitForSuggestionsToFadeOut(); editor.clickSaveAndContinue(); editor.clickCancel().edit(); userPicker = new UserClassFieldEditPane("user1").getUserPicker().waitToLoad(); selectedUsers = userPicker.getAcceptedSuggestions(); Assert.assertEquals(3, selectedUsers.size()); assertUserElement(selectedUsers.get(2), "foobar", "foobar", "noavatar.png"); Assert.assertEquals("", userPicker.getValue()); // Delete the fake user. selectedUsers.get(2).delete(); Assert.assertEquals(2, userPicker.getAcceptedSuggestions().size()); // Delete all selected users. userPicker.getClearSelectionLink().click(); editor.clickSaveAndContinue(); editor.clickCancel().edit(); userPicker = new UserClassFieldEditPane("user1").getUserPicker().waitToLoad(); Assert.assertEquals(0, userPicker.getAcceptedSuggestions().size()); Assert.assertEquals("", userPicker.getValue()); }
From source file:org.xwiki.test.ui.appwithinminutes.UserClassFieldTest.java
License:Open Source License
@Test public void testApplicationEntry() { // Create the application class. UserPicker userPicker = new UserClassFieldEditPane(editor.addField("User").getName()).getUserPicker(); userPicker.sendKeys("thomas").waitForSuggestions().sendKeys(Keys.ENTER); editor.clickSaveAndView();// w w w.j av a 2 s . com // Create the application entry. ClassSheetPage classSheetPage = new ClassSheetPage(); InlinePage entryEditPage = classSheetPage.createNewDocument(getTestClassName(), getTestMethodName() + "Entry"); // Assert the initial value. String id = getTestClassName() + "." + getTestMethodName() + "_0_user1"; userPicker = new UserPicker(getDriver().findElement(By.id(id))); List<UserElement> selectedUsers = userPicker.waitToLoad().getAcceptedSuggestions(); Assert.assertEquals(1, selectedUsers.size()); assertUserElement(selectedUsers.get(0), "Thomas Mortagne"); Assert.assertEquals("", userPicker.getValue()); // Change the selected user. userPicker.sendKeys("eduard").waitForSuggestions().sendKeys(Keys.ENTER).waitForSuggestionsToFadeOut(); // We wait for the page to load because Selenium doesn't do it all the time when Save & View is clicked. entryEditPage.clickSaveAndView().waitUntilPageIsLoaded(); // Assert the view mode. List<WebElement> users = getDriver().findElements(By.className("user")); Assert.assertEquals(1, users.size()); assertUserElement(new UserElement(users.get(0)), "Eduard Moraru", "Enygma2002"); }