List of usage examples for org.openqa.selenium Keys RETURN
Keys RETURN
To view the source code for org.openqa.selenium Keys RETURN.
Click Source Link
From source file:org.xwiki.appwithinminutes.test.po.StaticListItemsEditor.java
License:Open Source License
/** * Changes item label.// w ww . jav a 2 s. c o m * * @param value item value * @param newLabel the new item label */ public void setLabel(String value, String newLabel) { getItem(value).click(); labelInput.clear(); labelInput.sendKeys(newLabel + Keys.RETURN); }
From source file:org.xwiki.test.selenium.WikiEditorTest.java
License:Open Source License
/** * Tests that the specified tool bar button works. * /*from w ww. j a v a2 s . c o m*/ * @param buttonTitle the title of a tool bar button * @param format the format of the text inserted by the specified button * @param defaultText the default text inserted if there's no text selected in the text area */ private void testToolBarButton(String buttonTitle, String format, String defaultText) { editInWikiEditor(this.getClass().getSimpleName(), getTestMethodName(), SYNTAX); WebElement textArea = getDriver().findElement(By.id("content")); textArea.clear(); textArea.sendKeys("a"); String buttonLocator = "//img[@title = '" + buttonTitle + "']"; getSelenium().click(buttonLocator); // Type b and c on two different lines and move the caret after b. textArea.sendKeys("b", Keys.RETURN, "c", Keys.ARROW_LEFT, Keys.ARROW_LEFT); getSelenium().click(buttonLocator); // Move the caret after c, type d and e, then select d. textArea.sendKeys(Keys.PAGE_DOWN, Keys.END, "de", Keys.ARROW_LEFT, Keys.chord(Keys.SHIFT, Keys.ARROW_LEFT)); getSelenium().click(buttonLocator); if (defaultText.isEmpty()) { assertEquals("a" + format + "b" + format + "\nc" + format + "de", textArea.getAttribute("value")); } else { assertEquals(String.format("a" + format + "b" + format + "\nc" + format + "e", defaultText, defaultText, "d"), textArea.getAttribute("value")); } }
From source file:org.xwiki.test.ui.appwithinminutes.ApplicationNameTest.java
License:Open Source License
/** * Try to create an application with an empty name using the Enter key. */// ww w. jav a 2 s . c o m @Test @IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See http://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See http://jira.xwiki.org/browse/XE-1177") }) public void testEmptyAppNameWithEnter() { ApplicationCreatePage appCreatePage = ApplicationCreatePage.gotoPage(); Assert.assertFalse(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE)); // Press Enter key without typing the application name. appCreatePage.getApplicationNameInput().sendKeys(Keys.RETURN); appCreatePage.waitForApplicationNameError(); Assert.assertTrue(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE)); // Type the application name. appCreatePage.setApplicationName("B"); appCreatePage.waitForApplicationNamePreview(); Assert.assertFalse(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE)); // Clear the application name using the Backspace key. appCreatePage.getApplicationNameInput().sendKeys(Keys.BACK_SPACE); appCreatePage.waitForApplicationNameError(); Assert.assertTrue(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE)); // Try to create the application even if the error message is displayed. appCreatePage.getApplicationNameInput().sendKeys(Keys.RETURN); Assert.assertTrue(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE)); // Fix the application name and move to the next step using the Enter key. appCreatePage.setApplicationName(getTestMethodName()); appCreatePage.waitForApplicationNamePreview(); appCreatePage.getApplicationNameInput().sendKeys(Keys.RETURN); Assert.assertEquals("Class: " + getTestMethodName(), new ViewPage().getDocumentTitle()); }
From source file:org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase.java
License:Open Source License
public void typeTextThenEnter(String text) { getRichTextArea().sendKeys(text, Keys.RETURN); }
From source file:org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase.java
License:Open Source License
public void typeEnter(int nb) { sendKey(Keys.RETURN, nb, false); }
From source file:org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase.java
License:Open Source License
public void typeShiftEnter() { getRichTextArea().sendKeys(Keys.chord(Keys.SHIFT, Keys.RETURN)); }
From source file:org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase.java
License:Open Source License
public void typeControlEnter() { getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, Keys.RETURN)); }
From source file:org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase.java
License:Open Source License
public void typeMetaEnter() { getRichTextArea().sendKeys(Keys.chord(Keys.META, Keys.RETURN)); }
From source file:org.xwiki.test.wysiwyg.LineTest.java
License:Open Source License
/** * @see XWIKI-2991: Editor is losing the focus when pressing enter after an image *//* ww w . j a va 2 s .c o m*/ @Test public void testEnterAfterImage() { clickMenu(ImageTest.MENU_IMAGE); clickMenu(ImageTest.MENU_INSERT_ATTACHED_IMAGE); waitForDialogToLoad(); // wait for the main step of the dialog to load waitForElement("//*[contains(@class, 'xSelectorAggregatorStep')]"); // click the 'All pages' tab getSelenium().click("//div[. = 'All pages']"); String imageSpace = "XWiki"; waitForElement(ImageTest.SPACE_SELECTOR + "/option[@value = '" + imageSpace + "']"); getSelenium().select(ImageTest.SPACE_SELECTOR, imageSpace); String imagePage = "AdminSheet"; waitForElement(ImageTest.PAGE_SELECTOR + "/option[@value = '" + imagePage + "']"); getSelenium().select(ImageTest.PAGE_SELECTOR, imagePage); getSelenium().click("//div[@class = 'xPageChooser']//button[. = 'Update']"); String imageSelector = "//div[@class = 'xImagesSelector']//img[@title = 'import.png']"; waitForElement(imageSelector); getSelenium().click(imageSelector); clickButtonWithText("Select"); waitForElement("//*[contains(@class, 'xImageConfig')]"); clickButtonWithText("Insert Image"); waitForDialogToClose(); // Make sure the editor is focused. getRichTextArea().sendKeys(""); // The inserted image should be selected. By pressing the right arrow key the caret is not moved after the image // thus we are forced to collapse the selection to the end. getRichTextArea().executeScript("window.getSelection().collapseToEnd()"); // If the editor loses focus after pressing Enter then the next typed text won't be submitted. getRichTextArea().sendKeys(Keys.RETURN, "xyz"); // Submit the changes. If the editor lost focus after pressing Enter then the next line has no effect. blurRichTextArea(); clickEditPageInWikiSyntaxEditor(); // Check the result. assertEquals("[[image:XWiki.AdminSheet@import.png]]\n\nxyz", getFieldValue("content")); }
From source file:ryoji.selenium.AppTest.java
@Test public void testSearch() { this.driver.get("http://www.yahoo.co.jp/"); WebElement searchBox = this.driver.findElement(By.id("srchtxt")); searchBox.sendKeys("?"); this.driver.findElement(By.id("srchbtn")).click(); this.driver.findElements(By.tagName("a")).get(80).click(); String imageUrl = this.driver.findElements(By.tagName("img")).get(10).getAttribute("src"); if (imageUrl.startsWith("http")) { this.driver.get(imageUrl); }// w w w . j ava 2 s . com this.driver.get("http://google.com"); this.driver.findElement(By.id("lst-ib")).sendKeys("David Cameron"); this.driver.findElement(By.id("lst-ib")).sendKeys(Keys.RETURN); }