Example usage for org.openqa.selenium Keys ARROW_DOWN

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

Introduction

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

Prototype

Keys ARROW_DOWN

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

Click Source Link

Usage

From source file:org.vaadin.testbenchsauce.BaseTestBenchTestCase.java

protected void selectMultiSelectOptionByIndex(String caption, int listSelectIndex) {
    logStep.info("Setting multi-select with caption: " + caption + " to index: " + listSelectIndex);
    //Chrome driver and ghost driver don't support clicking multi selects well (on change isn't fired)- bug reports - due to https://code.google.com/p/chromedriver/issues/detail?id=496&q=select&colspec=ID%20Status%20Pri%20Owner%20Summary and https://code.google.com/p/chromedriver/issues/detail?id=169#c9
    //Workaround is to arrow down to the item (which does trigger the on change logic)
    WebElement selectElement = getSelectElement(caption);

    assertNotNull("Could not find the multi-select field '" + caption + "'.", selectElement);

    selectElement.sendKeys(Keys.HOME);// w  w w . j ava2  s . c  o  m
    for (int i = 0; i < listSelectIndex; i++) {
        selectElement.sendKeys(Keys.ARROW_DOWN);
    }
}

From source file:org.vaadin.testbenchsauce.BaseTestBenchTestCase.java

protected String selectComboBoxOptionByIndex(int optionIndex) {
    logStep.info("Selecting combobox(0) option index: " + optionIndex);

    WebElement comboBox = findElement(By.xpath("//div[contains(@class, 'v-filterselect')]"));
    WebElement filterSelectButton = comboBox.findElement(By.className("v-filterselect-button"));//show how to find this in the chrome dev tools
    filterSelectButton.click();/*w  w w  .  ja v a2s. c  o  m*/
    WebElement filterInput = comboBox.findElement(By.className("v-filterselect-input"));
    filterInput.sendKeys(Keys.ARROW_DOWN); //one to enter list selection
    for (int i = 0; i < optionIndex; i++) {
        filterInput.sendKeys(Keys.ARROW_DOWN);
    }
    filterInput.sendKeys(Keys.ENTER);
    return getElementValue(filterInput);
}

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();/*from   ww  w  .  ja  v  a2  s .  c  om*/
    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.wysiwyg.framework.AbstractWysiwygTestCase.java

License:Open Source License

public void typeDownArrow() {
    getRichTextArea().sendKeys(Keys.ARROW_DOWN);
}

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   www  . j a  v a 2  s. c  o  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.//  w w  w .  j  a  v  a  2s . c om
 */
@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

/**
 * Tests if the switch to WYSIWYG tab action can be canceled.
 *///from   ww  w.j a v  a 2 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));
}