List of usage examples for org.openqa.selenium Keys ARROW_RIGHT
Keys ARROW_RIGHT
To view the source code for org.openqa.selenium Keys ARROW_RIGHT.
Click Source Link
From source file:org.richfaces.tests.metamer.ftest.richCalendar.TestRF14032.java
License:Open Source License
@Test @IssueTracking("https://issues.jboss.org/browse/RF-14032") public void testSelectedYearWillChangeOnlyByArrowsPressing() { // set some reference date Graphene.guardAjax(popupCalendar).setDateTime(firstOfJanuary2012); waitUtilNoTimeoutsArePresent();//from w w w . jav a 2s . c o m PopupCalendar popup = popupCalendar.openPopup(); // set a different year and month than the reference date popup.getHeaderControls().openYearAndMonthEditor().selectDate(todayMidday).confirmDate(); DayPicker dayPicker = popup.getDayPicker(); // key press >>> selected day in day picker will NOT change keyboard.sendKeys("a"); assertNull(dayPicker.getSelectedDay()); // key press >>> selected day in day picker will NOT change keyboard.sendKeys(Keys.CONTROL); assertNull(dayPicker.getSelectedDay()); // arrow press >>> selected day in day picker will change keyboard.sendKeys(Keys.ARROW_RIGHT); assertNotNull(dayPicker.getSelectedDay()); // 1st january + arrow right >>> 2nd January assertEquals(dayPicker.getSelectedDay().getDayNumber(), Integer.valueOf(2)); }
From source file:org.safs.selenium.webdriver.lib.WDLibrary.java
License:Open Source License
/** * Convert a Java KEYCODE to a Selenium WebDriver Keys Enum * @param keycode int, a java keycode/*w ww . j ava 2 s . c om*/ * @return Keys enum for (primarily) non-printable (control) characters, or null. */ public static Keys convertToKeys(int keycode) { Keys key = null; switch (keycode) { case java.awt.event.KeyEvent.VK_ADD: key = Keys.ADD; break; case java.awt.event.KeyEvent.VK_ALT: key = Keys.ALT; break; case java.awt.event.KeyEvent.VK_KP_DOWN: key = Keys.ARROW_DOWN; break; case java.awt.event.KeyEvent.VK_KP_LEFT: key = Keys.ARROW_LEFT; break; case java.awt.event.KeyEvent.VK_KP_RIGHT: key = Keys.ARROW_RIGHT; break; case java.awt.event.KeyEvent.VK_KP_UP: key = Keys.ARROW_UP; break; case java.awt.event.KeyEvent.VK_BACK_SPACE: key = Keys.BACK_SPACE; break; case java.awt.event.KeyEvent.VK_CANCEL: key = Keys.CANCEL; break; case java.awt.event.KeyEvent.VK_CLEAR: key = Keys.CLEAR; break; case java.awt.event.KeyEvent.VK_WINDOWS: key = Keys.COMMAND; break; case java.awt.event.KeyEvent.VK_CONTROL: key = Keys.CONTROL; break; case java.awt.event.KeyEvent.VK_DECIMAL: key = Keys.DECIMAL; break; case java.awt.event.KeyEvent.VK_DELETE: key = Keys.DELETE; break; case java.awt.event.KeyEvent.VK_DIVIDE: key = Keys.DIVIDE; break; case java.awt.event.KeyEvent.VK_DOWN: key = Keys.DOWN; break; case java.awt.event.KeyEvent.VK_END: key = Keys.END; break; case java.awt.event.KeyEvent.VK_ENTER: key = Keys.ENTER; break; case java.awt.event.KeyEvent.VK_EQUALS: key = Keys.EQUALS; break; case java.awt.event.KeyEvent.VK_ESCAPE: key = Keys.ESCAPE; break; case java.awt.event.KeyEvent.VK_F1: key = Keys.F1; break; case java.awt.event.KeyEvent.VK_F2: key = Keys.F2; break; case java.awt.event.KeyEvent.VK_F3: key = Keys.F3; break; case java.awt.event.KeyEvent.VK_F4: key = Keys.F4; break; case java.awt.event.KeyEvent.VK_F5: key = Keys.F5; break; case java.awt.event.KeyEvent.VK_F6: key = Keys.F6; break; case java.awt.event.KeyEvent.VK_F7: key = Keys.F7; break; case java.awt.event.KeyEvent.VK_F8: key = Keys.F8; break; case java.awt.event.KeyEvent.VK_F9: key = Keys.F9; break; case java.awt.event.KeyEvent.VK_F10: key = Keys.F10; break; case java.awt.event.KeyEvent.VK_F11: key = Keys.F11; break; case java.awt.event.KeyEvent.VK_F12: key = Keys.F12; break; case java.awt.event.KeyEvent.VK_HELP: key = Keys.HELP; break; case java.awt.event.KeyEvent.VK_HOME: key = Keys.HOME; break; case java.awt.event.KeyEvent.VK_INSERT: key = Keys.INSERT; break; case java.awt.event.KeyEvent.VK_LEFT: key = Keys.LEFT; break; case java.awt.event.KeyEvent.VK_META: key = Keys.META; break; case java.awt.event.KeyEvent.VK_MULTIPLY: key = Keys.MULTIPLY; break; case java.awt.event.KeyEvent.VK_NUMPAD0: key = Keys.NUMPAD0; break; case java.awt.event.KeyEvent.VK_NUMPAD1: key = Keys.NUMPAD1; break; case java.awt.event.KeyEvent.VK_NUMPAD2: key = Keys.NUMPAD2; break; case java.awt.event.KeyEvent.VK_NUMPAD3: key = Keys.NUMPAD3; break; case java.awt.event.KeyEvent.VK_NUMPAD4: key = Keys.NUMPAD4; break; case java.awt.event.KeyEvent.VK_NUMPAD5: key = Keys.NUMPAD5; break; case java.awt.event.KeyEvent.VK_NUMPAD6: key = Keys.NUMPAD6; break; case java.awt.event.KeyEvent.VK_NUMPAD7: key = Keys.NUMPAD7; break; case java.awt.event.KeyEvent.VK_NUMPAD8: key = Keys.NUMPAD8; break; case java.awt.event.KeyEvent.VK_NUMPAD9: key = Keys.NUMPAD9; break; case java.awt.event.KeyEvent.VK_PAGE_DOWN: key = Keys.PAGE_DOWN; break; case java.awt.event.KeyEvent.VK_PAGE_UP: key = Keys.PAGE_UP; break; case java.awt.event.KeyEvent.VK_PAUSE: key = Keys.PAUSE; break; case java.awt.event.KeyEvent.VK_RIGHT: key = Keys.RIGHT; break; case java.awt.event.KeyEvent.VK_SEMICOLON: key = Keys.SEMICOLON; break; case java.awt.event.KeyEvent.VK_SEPARATOR: key = Keys.SEPARATOR; break; case java.awt.event.KeyEvent.VK_SHIFT: key = Keys.SHIFT; break; case java.awt.event.KeyEvent.VK_SPACE: key = Keys.SPACE; break; case java.awt.event.KeyEvent.VK_SUBTRACT: key = Keys.SUBTRACT; break; case java.awt.event.KeyEvent.VK_TAB: key = Keys.TAB; break; case java.awt.event.KeyEvent.VK_UP: key = Keys.UP; break; } return key; }
From source file:org.xmlium.test.web.commons.xml.XMLTestSteps.java
License:LGPL
protected void checkMoveX(Element e, WebElement element) { if (e.getMoveX() != null && e.getElement() != null) { int len = e.getMoveX().intValue(); Keys key = Keys.ARROW_RIGHT; if (e.getMoveX().intValue() < 0) { len = -e.getMoveX().intValue(); key = Keys.ARROW_LEFT;// ww w . ja va 2s . c o m } logger.debug("len=" + len); for (int i = 0; i < len; i++) { logger.debug("in loop: i=" + i); try { Thread.sleep(120); } catch (Exception e2) { // TODO: handle exception } element = findElement(e.getFinds()); element.sendKeys(key); } } }
From source file:org.xwiki.test.selenium.AdministrationTest.java
License:Open Source License
@Test public void testCodeToExecutionAndAutoSandboxing() { String space = "Main"; String page = "TestConfigurable"; String codeToExecute = "#set($code = 's sh')" + "Thi${code}ould be displayed." + "#if($xcontext.hasProgrammingRights())" + "This should not be displayed." + "#end"; String heading = "#set($code = 'his sho')" + "T${code}uld also be displayed."; createConfigurableApplication(space, page, "TestSection6", true); open(space, page, "edit", "editor=object"); expandObject("XWiki.ConfigurableClass", 0); setFieldValue("XWiki.ConfigurableClass_0_codeToExecute", codeToExecute); setFieldValue("XWiki.ConfigurableClass_0_heading", heading); setFieldValue("XWiki.ConfigurableClass_0_configurationClass", ""); clickEditSaveAndView();/* w w w. j a va2 s .co m*/ // Our admin will foolishly save XWiki.ConfigurableClass, giving it programming rights. open("XWiki", "ConfigurableClass", "edit", "editor=wiki"); try { // Since we modify ConfigurableClass, we must modify it back after to prevent polluting further tests. // See http://code.google.com/p/selenium/issues/detail?id=2876 . getDriver().findElement(By.id("content")).sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.chord(Keys.CONTROL, "c"), Keys.ARROW_RIGHT, "{{velocity}}Has Programming permission: $xcontext.hasProgrammingRights(){{/velocity}}"); clickEditSaveAndContinue(); // Now we look at the section for our configurable. open("XWiki", "ConfigurableClass", "view", "editor=globaladmin§ion=TestSection6"); assertTextPresent("This should be displayed."); assertTextPresent("This should also be displayed."); assertTextNotPresent("This should not be displayed."); assertTextPresent("Has Programming permission: false"); // Make sure javascript has not added a Save button. assertElementNotPresent("//div/div/p/span/input[@type='submit'][@value='Save']"); } finally { open("XWiki", "ConfigurableClass", "edit", "editor=wiki"); getDriver().findElement(By.id("content")).sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.chord(Keys.CONTROL, "v")); clickEditSaveAndContinue(); } }
From source file:org.xwiki.test.ui.XWikiWebDriver.java
License:Open Source License
/** * Compared to using clear() + sendKeys(), this method ensures that an "input" event is triggered on the JavaScript * side for an empty ("") value. Without this, the clear() method triggers just a "change" event. * * @param textInputElement an element accepting text input * @param newTextValue the new text value to set * @see <a href="https://code.google.com/p/selenium/issues/detail?id=214">Issue 214</a> * @since 7.2M3/*from ww w . ja v a2s.c o m*/ */ public void setTextInputValue(WebElement textInputElement, String newTextValue) { if (StringUtils.isEmpty(newTextValue)) { // Workaround for the fact that clear() fires the "change" event but not the "input" event and javascript // listening to the "input" event will not be executed otherwise. // Note 1: We're not using CTRL+A and the Delete because the key combination to select the full input // depends on the OS (on Mac it's META+A for example). // Note 2: Sending the END key didn't always work when I tested it on Mac (for some unknown reason) textInputElement.click(); textInputElement.sendKeys(StringUtils.repeat(Keys.ARROW_RIGHT.toString(), textInputElement.getAttribute("value").length())); textInputElement.sendKeys(StringUtils.repeat(Keys.BACK_SPACE.toString(), textInputElement.getAttribute("value").length())); } else { textInputElement.clear(); textInputElement.sendKeys(newTextValue); } }
From source file:org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase.java
License:Open Source License
public void typeRightArrow() { getRichTextArea().sendKeys(Keys.ARROW_RIGHT); }
From source file:org.xwiki.test.wysiwyg.TabsTest.java
License:Open Source License
/** * Switches to source tab while the rich text area is still loading. The source text must remain unchanged. *//* ww w.ja va 2 s . co m*/ @Test public void testSwitchToSourceWhileWysiwygIsLoading() { switchToSource(); StringBuffer sourceText = new StringBuffer(); sourceText.append("{{code language=\"java\"}}\n"); sourceText.append("public interface Command {\n"); sourceText.append(" boolean execute(String parameter);\n"); sourceText.append("}\n"); sourceText.append("{{/code}}"); setSourceText(sourceText.toString()); // Set the cursor position before "language" to see if it is preserved. getSourceTextArea().sendKeys(Keys.HOME, Keys.PAGE_UP, Keys.chord(Keys.CONTROL, Keys.ARROW_RIGHT), Keys.ARROW_RIGHT); // Switch to WYSIWYG tab but don't wait for the rich text area to load. switchToWysiwyg(false); // Switch back to source tab. switchToSource(); getSourceTextArea().sendKeys("x"); // Check the source text. We don't assert the cursor position directly because it isn't available when the test // is run in background. assertSourceText(sourceText.substring(0, 7) + "x" + sourceText.substring(7)); }
From source file:org.xwiki.test.wysiwyg.TabsTest.java
License:Open Source License
/** * Tests if the switch to WYSIWYG tab action can be canceled. *//* w ww . j av a2 s .c o m*/ @Test public void testCancelSwitchToWysiwyg() { // Switch to source tab and insert some content that takes time to render. A code macro is perfect for this. switchToSource(); StringBuilder sourceText = new StringBuilder(); sourceText.append("{{code language=\"java\"}}\n"); sourceText.append("public final class Apple extends Fruit {\n"); sourceText.append(" public String getColor() {\n"); sourceText.append(" return \"red\";\n"); sourceText.append(" }\n"); sourceText.append("}\n"); sourceText.append("{{/code}}"); setSourceText(sourceText.toString()); // Place the caret before "Apple". getSourceTextArea().sendKeys(Keys.HOME, Keys.PAGE_UP, Keys.ARROW_DOWN, Keys.chord(Keys.CONTROL, Keys.ARROW_RIGHT, Keys.ARROW_RIGHT, Keys.ARROW_RIGHT), Keys.ARROW_RIGHT); // Switch to rich text but don't wait till the rich text area finishes loading. switchToWysiwyg(false); // Switch back to source before the rich text area is reloaded. switchToSource(); // Change the content. getSourceTextArea().sendKeys("X"); // Switch to WYSIWYG tab again, this time with a different source text. Wait for the rich text area to load. switchToWysiwyg(); // Check the result. switchToSource(); getSourceTextArea().sendKeys("Y"); assertSourceText(sourceText.substring(0, 44) + "XY" + sourceText.substring(44)); }
From source file:org.xwiki.test.wysiwyg.TabsTest.java
License:Open Source License
/** * Switches to source tab, changes the source text then switches back to WYSIWYG tab and undoes the change. *//*from w ww. j a v a 2 s . co m*/ @Test public void testUndoSourceChange() { typeText("1"); applyStyleTitle1(); switchToSource(); // Change the source text. getSourceTextArea().sendKeys(Keys.ARROW_RIGHT, Keys.ARROW_RIGHT, Keys.ARROW_RIGHT, "2"); // Switch to WYSIWYG tab and undo the change. switchToWysiwyg(); // The tool bar is not updated right away. We have to wait for the undo push button to become enabled. waitForPushButton(TOOLBAR_BUTTON_UNDO_TITLE, true); clickUndoButton(); // Check the result. switchToSource(); // NOTE: This is not the right result since the heading style was removed also. This needs to be fixed. assertSourceText("1"); }
From source file:org.xwiki.wysiwyg.test.ui.EditWYSIWYGTest.java
License:Open Source License
/** * Test that hitting the . (dot) key at the end of a list item does not act as delete. * // w w w .j a v a2s .c o m * @see <a href="http://jira.xwiki.org/jira/browse/XWIKI-3304">XWIKI-3304</a> */ @Test @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See http://jira.xwiki.org/browse/XE-1146") public void testDotAtEndDoesNotDelete() { EditorElement editor = this.editPage.getContentEditor(); // Create a list with two items. editor.switchToSource(); WebElement sourceTextArea = editor.getSourceTextArea(); sourceTextArea.clear(); sourceTextArea.sendKeys("* foo\n* bar"); editor.switchToWysiwyg(); // Place the caret at the end of the first item and type dot. RichTextAreaElement textArea = editor.getRichTextArea(); textArea.sendKeys(Keys.ARROW_RIGHT, Keys.ARROW_RIGHT, Keys.ARROW_RIGHT, "."); Assert.assertEquals("foo.\nbar", textArea.getText()); }