List of usage examples for org.openqa.selenium Keys CONTROL
Keys CONTROL
To view the source code for org.openqa.selenium Keys CONTROL.
Click Source Link
From source file:org.xwiki.test.wysiwyg.framework.XWikiExplorer.java
License:Open Source License
private XWikiExplorer toggleSelection(String nodeId) { WebElement node = this.driver .findElementByXPath(getNodeLocator(nodeId) + "/a[contains(@class, 'jstree-anchor')]"); new Actions(this.driver).keyDown(Keys.CONTROL).click(node).keyUp(Keys.CONTROL).perform(); return this; }
From source file:org.xwiki.test.wysiwyg.HistoryTest.java
License:Open Source License
/** * Tests the shortcut keys for undo and redo operations. Undo is triggered by CTRL+Z or META+Z. The second is used * on apple keyboards. Redo is triggered by CTRL+Y or META+Y. The second is also used on apple keyboards. * //from w w w . j a v a 2s . c o m * @see XWIKI-3048: Undo/Redo/Copy/Paste/Cut Mac shortcuts should be mapped to the corresponding features of the * WYSIWYG editor */ @Test public void testUndoRedoShortcutKeys() { setContent("March 9th, 2009"); select("document.body.firstChild", 0, "document.body.firstChild", 5); // Make text bold. getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "b")); // Make text italic. // FIXME: getRichTextArea().sendKeys(Keys.chord(Keys.META, "i")); getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "i")); // Make text underline. getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "u")); // Undo last 3 steps. // The undo tool bar button is initially disabled because no action has been taken on the edited document. We // have to wait for it to become enabled because the tool bar is updated with delay after each edit action. waitForPushButton(TOOLBAR_BUTTON_UNDO_TITLE, true); // FIXME: getRichTextArea().sendKeys(Keys.chord(Keys.META, "zzz")); getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "zzz")); // Redo 2 steps. // We have to wait for the redo tool bar button to become enabled because the tool bar is updated with delay // after an undo operation. waitForPushButton(TOOLBAR_BUTTON_REDO_TITLE, true); getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "yy")); switchToSource(); assertSourceText("**//March//** 9th, 2009"); }
From source file:org.xwiki.test.wysiwyg.MacroTest.java
License:Open Source License
/** * Collapses the currently selected macro or, if none is selected, all the macros using the shortcut key. *///from w w w. j ava 2 s . c om public void collapseMacrosUsingShortcutKey() { getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, Keys.SHIFT, "c")); }
From source file:org.xwiki.test.wysiwyg.MacroTest.java
License:Open Source License
/** * Expands the currently selected macro or, if none is selected, all the macros using the shortcut key. *//* ww w .j ava 2s . c om*/ public void expandMacrosUsingShortcutKey() { getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, Keys.SHIFT, "e")); }
From source file:org.xwiki.test.wysiwyg.MacroTest.java
License:Open Source License
/** * Refreshes the macros present in the edited document using the shortcut key. *///from w w w .j a v a 2 s.c o m public void refreshMacrosUsingShortcutKey() { getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, Keys.SHIFT, "r")); waitForEditorToLoad(); }
From source file:org.xwiki.test.wysiwyg.StandardFeaturesTest.java
License:Open Source License
/** * @see XWIKI-4665: Pressing Meta+G (Jump to page) in the WYSIWYG editor displays the popup inside the rich text * area.//ww w . j ava 2s .co m */ @Test public void testJavaScriptExtensionsAreNotIncludedInEditMode() { // Type some text to be sure the conversion is triggered when switching to source. typeText("x"); // Type Ctrl+G to open the "Jump to page" dialog. getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "g")); // Switch to source and check the result. switchToSource(); assertSourceText("x"); // Now check that the "Jump to page" feature works indeed. String jumpToPageTitleXPath = "//div[@class = 'xdialog-title' and starts-with(., 'Go to:')]"; assertElementNotPresent(jumpToPageTitleXPath); getSourceTextArea().sendKeys(Keys.chord(Keys.CONTROL, "g")); assertElementPresent(jumpToPageTitleXPath); // Ctrl+G is a shortcut for "Find again" on Firefox and it opens the find toolbar at the bottom of the page. // This toolbar can influence the way Selenium/WebDriver computes the position of the buttons on the page // leading to cases where clicking on a button has no action because the click is performed at a different // location or because Selenium thinks the location is outside of the page. // Close the "Jump to page" dialog, switch back to rich text area and close the find toolbar. getSourceTextArea().sendKeys(Keys.ESCAPE); switchToWysiwyg(); getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "g"), Keys.ESCAPE); }
From source file:org.xwiki.test.wysiwyg.TableTest.java
License:Open Source License
/** * @see XWIKI-3090: Cannot move cursor before table * @see XWIKI-3089: Cannot move cursor after table * @see XWIKI-3829: Use Control/Meta+Up/Down arrow keys to navigate before/after a table *///from w ww .ja v a 2s . co m @Test public void testMoveCaretBeforeAndAfterTable() { switchToSource(); setSourceText("|=Space|=Page\n|Main|WebHome"); switchToWysiwyg(); // Place the caret in one of the table cells. moveCaret("document.body.getElementsByTagName('table')[0].rows[0].cells[0].firstChild", 2); // Move the caret before the table and type some text. This time using Control+Up. getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, Keys.ARROW_UP), "1"); // Place the caret again in one of the table cells. moveCaret("document.body.getElementsByTagName('table')[0].rows[0].cells[0].firstChild", 2); // Move the caret before the table and type some text. This time using Meta+Up. // FIXME: Selenium doesn't simulate correctly the Meta key. // getRichTextArea().sendKeys(Keys.chord(Keys.META, Keys.ARROW_UP), "2"); // Place the caret again in one of the table cells. moveCaret("document.body.getElementsByTagName('table')[0].rows[1].cells[1].firstChild", 3); // Move the caret after the table and type some text. This time using Control+Down. getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, Keys.ARROW_DOWN), "4"); // Place the caret again in one of the table cells. moveCaret("document.body.getElementsByTagName('table')[0].rows[1].cells[1].firstChild", 3); // Move the caret after the table and type some text. This time using Meta+Down. // FIXME: Selenium doesn't simulate correctly the Meta key. // getRichTextArea().sendKeys(Keys.chord(Keys.META, Keys.ARROW_DOWN), "3"); switchToSource(); assertSourceText("1\n\n|=Space|=Page\n|Main|WebHome\n\n4"); }
From source file:org.xwiki.test.wysiwyg.TableTest.java
License:Open Source License
/** * @see XWIKI-4017: The close X button from the "Insert Table" dialog acts like the "Insert" button after a table * has been inserted./*www . ja v a2 s . c o m*/ */ @Test public void testCancelInsertTable() { openInsertTableDialog(); // Cancel the insert table operation. closeDialog(); // Insert a default table this time. insertTable(); // Move the caret after the table. getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, Keys.ARROW_DOWN)); openInsertTableDialog(); // Cancel the insert table operation again. closeDialog(); // Check the result. switchToSource(); assertSourceText("|= |= \n| | \n"); }
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. *//*from w ww . ja va2s . c o 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
/** * Switches to source tab without changing the HTML. The source selection should be preserved. *//*from w ww.j av a 2 s .co m*/ @Test public void testSwitchToSourceWithoutHTMLChanges() { switchToSource(); String sourceText = "one **two** three"; setSourceText(sourceText); // Move the caret between the first two *. getSourceTextArea().sendKeys(Keys.chord(Keys.CONTROL, Keys.ARROW_LEFT, Keys.ARROW_LEFT), Keys.ARROW_LEFT); switchToWysiwyg(); // Switch back to source tab without changing the HTML. switchToSource(); getSourceTextArea().sendKeys("x"); // Check the source text. assertSourceText(sourceText.substring(0, 5) + "x" + sourceText.substring(5)); }