Example usage for org.openqa.selenium Keys ARROW_LEFT

List of usage examples for org.openqa.selenium Keys ARROW_LEFT

Introduction

In this page you can find the example usage for org.openqa.selenium Keys ARROW_LEFT.

Prototype

Keys ARROW_LEFT

To view the source code for org.openqa.selenium Keys ARROW_LEFT.

Click Source Link

Usage

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;/*from w ww. j a v  a  2 s  . c om*/
        if (e.getMoveX().intValue() < 0) {
            len = -e.getMoveX().intValue();
            key = Keys.ARROW_LEFT;
        }
        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.WikiEditorTest.java

License:Open Source License

/**
 * Tests that the specified tool bar button works.
 * /* w ww  .  j a v a 2 s .c  om*/
 * @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.wysiwyg.framework.AbstractWysiwygTestCase.java

License:Open Source License

public void typeLeftArrow() {
    getRichTextArea().sendKeys(Keys.ARROW_LEFT);
}

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.
 *//* ww w. j ava2s  .  c om*/
@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));
}

From source file:org.xwiki.wysiwyg.test.ui.EditWYSIWYGTest.java

License:Open Source License

/**
 * Test if an undo step reverts only one paste operation from a sequence, and not all of them.
 */// w w w  .  j  av  a2s.  co  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 testUndoRepeatedPaste() {
    EditorElement editor = this.editPage.getContentEditor();
    RichTextAreaElement textArea = editor.getRichTextArea();
    // Type text, select it (Shift+LeftArrow) and copy it (Control+C).
    // NOTE: We don't use Control+A to select the text because it selects also the BR element.
    textArea.sendKeys("q", Keys.chord(Keys.SHIFT, Keys.ARROW_LEFT), Keys.chord(Keys.CONTROL, "c"));
    // Then paste it 4 times (Control+V).
    for (int i = 0; i < 4; i++) {
        // Release the key after each paste so that the history records an entry for each paste. In case the paste
        // content is cleaned automatically, the editor cleans consecutive paste events (that happen one after
        // another) together and so a single history entry is recorded for such a group of paste events.
        textArea.sendKeys(Keys.chord(Keys.CONTROL, "v"));
    }
    // Undo the last paste.
    editor.getToolBar().clickUndoButton();
    Assert.assertEquals("qqq", textArea.getText());
}