Example usage for org.openqa.selenium Keys ENTER

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

Introduction

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

Prototype

Keys ENTER

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

Click Source Link

Usage

From source file:org.apache.zeppelin.integration.ParagraphActionsIT.java

License:Apache License

public void testEditOnDoubleClick() throws Exception {
    try {/*from   ww w .j ava 2  s . c o  m*/
        createNewNote();
        Actions action = new Actions(driver);

        waitForParagraph(1, "READY");

        setTextOfParagraph(1, "%md");
        driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")).sendKeys(Keys.ARROW_RIGHT);
        driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")).sendKeys(Keys.ENTER);
        driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")).sendKeys(Keys.SHIFT + "3");
        driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")).sendKeys(" abc");

        runParagraph(1);
        waitForParagraph(1, "FINISHED");

        collector.checkThat("Markdown editor is hidden after run ",
                driver.findElements(By
                        .xpath(getParagraphXPath(1) + "//div[contains(@ng-if, 'paragraph.config.editorHide')]"))
                        .size(),
                CoreMatchers.equalTo(0));

        collector.checkThat("Markdown editor is shown after run ",
                driver.findElement(By.xpath(
                        getParagraphXPath(1) + "//div[contains(@ng-show, 'paragraph.config.tableHide')]"))
                        .isDisplayed(),
                CoreMatchers.equalTo(true));

        // to check if editOnDblClick field is fetched correctly after refresh
        driver.navigate().refresh();
        waitForParagraph(1, "FINISHED");

        action.doubleClick(driver.findElement(By.xpath(getParagraphXPath(1)))).perform();
        ZeppelinITUtils.sleep(1000, false);
        collector.checkThat("Markdown editor is shown after double click ",
                driver.findElement(By
                        .xpath(getParagraphXPath(1) + "//div[contains(@ng-if, 'paragraph.config.editorHide')]"))
                        .isDisplayed(),
                CoreMatchers.equalTo(true));

        collector.checkThat("Markdown editor is hidden after double click ",
                driver.findElement(By.xpath(
                        getParagraphXPath(1) + "//div[contains(@ng-show, 'paragraph.config.tableHide')]"))
                        .isDisplayed(),
                CoreMatchers.equalTo(false));

        deleteTestNotebook(driver);

    } catch (Exception e) {
        handleException("Exception in ParagraphActionsIT while testEditOnDoubleClick ", e);
    }
}

From source file:org.apache.zeppelin.integration.ZeppelinIT.java

License:Apache License

@Test
public void testAngularDisplay() throws Exception {
    try {//w ww. jav  a2  s  .co m
        createNewNote();

        // wait for first paragraph's " READY " status text
        waitForParagraph(1, "READY");

        /*
         * print angular template
         * %angular <div id='angularTestButton' ng-click='myVar=myVar+1'>BindingTest_{{myVar}}_</div>
         */
        setTextOfParagraph(1,
                "%angular <div id=\\'angularTestButton\\' ng-click=\\'myVar=myVar+1\\'>BindingTest_{{myVar}}_</div>");
        runParagraph(1);
        waitForParagraph(1, "FINISHED");

        // check expected text
        waitForText("BindingTest__", By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]"));

        /*
         * Bind variable
         * z.angularBind("myVar", 1)
         */
        assertEquals(1, driver.findElements(By.xpath(getParagraphXPath(2) + "//textarea")).size());
        setTextOfParagraph(2, "z.angularBind(\"myVar\", 1)");
        runParagraph(2);
        waitForParagraph(2, "FINISHED");

        // check expected text
        waitForText("BindingTest_1_", By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]"));

        /*
         * print variable
         * print("myVar="+z.angular("myVar"))
         */
        setTextOfParagraph(3, "print(\"myVar=\"+z.angular(\"myVar\"))");
        runParagraph(3);
        waitForParagraph(3, "FINISHED");

        // check expected text
        waitForText("myVar=1",
                By.xpath(getParagraphXPath(3) + "//div[contains(@id,\"_text\") and @class=\"text\"]"));

        /*
         * Click element
         */
        driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).click();

        // check expected text
        waitForText("BindingTest_2_", By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]"));

        /*
         * Register watcher
         * z.angularWatch("myVar", (before:Object, after:Object, context:org.apache.zeppelin.interpreter.InterpreterContext) => {
         *   z.run(2, context)
         * }
         */
        setTextOfParagraph(4,
                "z.angularWatch(\"myVar\", (before:Object, after:Object, context:org.apache.zeppelin.interpreter.InterpreterContext)=>{ z.run(2, false)})");
        runParagraph(4);
        waitForParagraph(4, "FINISHED");

        /*
         * Click element, again and see watcher works
         */
        driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).click();

        // check expected text
        waitForText("BindingTest_3_", By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]"));
        waitForParagraph(3, "FINISHED");

        // check expected text by watcher
        waitForText("myVar=3",
                By.xpath(getParagraphXPath(3) + "//div[contains(@id,\"_text\") and @class=\"text\"]"));

        /*
         * Click element, again and see watcher still works
         */
        driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).click();
        // check expected text
        waitForText("BindingTest_4_", By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]"));
        waitForParagraph(3, "FINISHED");

        // check expected text by watcher
        waitForText("myVar=4",
                By.xpath(getParagraphXPath(3) + "//div[contains(@id,\"_text\") and @class=\"text\"]"));

        /*
         * Unbind
         * z.angularUnbind("myVar")
         */
        setTextOfParagraph(5, "z.angularUnbind(\"myVar\")");
        runParagraph(5);
        waitForParagraph(5, "FINISHED");

        // check expected text
        waitForText("BindingTest__", By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]"));

        /*
         * Bind again and see rebind works.
         */
        runParagraph(2);
        waitForParagraph(2, "FINISHED");

        // check expected text
        waitForText("BindingTest_1_", By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]"));

        driver.findElement(By.xpath(".//*[@id='main']//button[@ng-click='moveNoteToTrash(note.id)']"))
                .sendKeys(Keys.ENTER);
        ZeppelinITUtils.sleep(1000, false);
        driver.findElement(
                By.xpath("//div[@class='modal-dialog'][contains(.,'This note will be moved to trash')]"
                        + "//div[@class='modal-footer']//button[contains(.,'OK')]"))
                .click();
        ZeppelinITUtils.sleep(100, false);

        LOG.info("testCreateNotebook Test executed");
    } catch (Exception e) {
        handleException("Exception in ZeppelinIT while testAngularDisplay ", e);
    }
}

From source file:org.apache.zeppelin.integration.ZeppelinIT.java

License:Apache License

@Test
public void testSparkInterpreterDependencyLoading() throws Exception {
    try {/*ww  w.  j a va 2s  .co m*/
        // navigate to interpreter page
        WebElement settingButton = driver
                .findElement(By.xpath("//button[@class='nav-btn dropdown-toggle ng-scope']"));
        settingButton.click();
        WebElement interpreterLink = driver.findElement(By.xpath("//a[@href='#/interpreter']"));
        interpreterLink.click();

        // add new dependency to spark interpreter
        driver.findElement(By.xpath("//div[@id='spark']//button[contains(.,'edit')]")).sendKeys(Keys.ENTER);

        WebElement depArtifact = pollingWait(By.xpath("//input[@ng-model='setting.depArtifact']"),
                MAX_BROWSER_TIMEOUT_SEC);
        String artifact = "org.apache.commons:commons-csv:1.1";
        depArtifact.sendKeys(artifact);
        driver.findElement(By.xpath("//div[@id='spark']//form//button[1]")).click();
        clickAndWait(By.xpath(
                "//div[@class='modal-dialog'][contains(.,'Do you want to update this interpreter and restart with new settings?')]"
                        + "//div[@class='modal-footer']//button[contains(.,'OK')]"));

        try {
            clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to "
                    + "update this interpreter and restart with new settings?')]//"
                    + "div[@class='bootstrap-dialog-close-button']/button"));
        } catch (TimeoutException | StaleElementReferenceException e) {
            //Modal dialog got closed earlier than expected nothing to worry.
        }

        driver.navigate().back();
        createNewNote();

        // wait for first paragraph's " READY " status text
        waitForParagraph(1, "READY");

        setTextOfParagraph(1, "import org.apache.commons.csv.CSVFormat");
        runParagraph(1);
        waitForParagraph(1, "FINISHED");

        // check expected text
        WebElement paragraph1Result = driver
                .findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@id,\"_text\")]"));

        collector.checkThat("Paragraph from ZeppelinIT of testSparkInterpreterDependencyLoading result: ",
                paragraph1Result.getText().toString(),
                CoreMatchers.containsString("import org.apache.commons.csv.CSVFormat"));

        //delete created notebook for cleanup.
        deleteTestNotebook(driver);
        ZeppelinITUtils.sleep(1000, false);

        // reset dependency
        settingButton.click();
        interpreterLink.click();
        driver.findElement(By.xpath("//div[@id='spark']//button[contains(.,'edit')]")).sendKeys(Keys.ENTER);
        WebElement testDepRemoveBtn = pollingWait(
                By.xpath("//tr[descendant::text()[contains(.,'" + artifact + "')]]/td[3]/button"),
                MAX_IMPLICIT_WAIT);
        testDepRemoveBtn.sendKeys(Keys.ENTER);
        driver.findElement(By.xpath("//div[@id='spark']//form//button[1]")).click();
        driver.findElement(By.xpath(
                "//div[@class='modal-dialog'][contains(.,'Do you want to update this interpreter and restart with new settings?')]"
                        + "//div[@class='modal-footer']//button[contains(.,'OK')]"))
                .click();
    } catch (Exception e) {
        handleException("Exception in ZeppelinIT while testSparkInterpreterDependencyLoading ", e);
    }
}

From source file:org.apache.zeppelin.ZeppelinIT.java

License:Apache License

@Test
public void testAngularDisplay() throws InterruptedException {
    if (!endToEndTestEnabled()) {
        return;//from  w w w  .ja v a2  s  . c  om
    }

    String noteName = createNewNoteAndGetName();
    driver.findElement(By.partialLinkText(noteName)).click();

    // wait for first paragraph's " READY " status text
    waitForParagraph(1, "READY");

    /*
     * print angular template
     * %angular <div id='angularTestButton' ng-click='myVar=myVar+1'>BindingTest_{{myVar}}_</div>
     */
    WebElement paragraph1Editor = driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea"));
    paragraph1Editor.sendKeys("println" + Keys.chord(Keys.SHIFT, "9") + "\"" + Keys.chord(Keys.SHIFT, "5")
            + "angular <div id='angularTestButton' " + "ng" + Keys.chord(Keys.SUBTRACT)
            + "click='myVar=myVar+1'>" + "BindingTest_{{myVar}}_</div>\")");
    paragraph1Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER));
    waitForParagraph(1, "FINISHED");

    // check expected text
    assertEquals("BindingTest__",
            driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).getText());

    /*
     * Bind variable
     * z.angularBind("myVar", 1)
     */
    assertEquals(1, driver.findElements(By.xpath(getParagraphXPath(2) + "//textarea")).size());
    WebElement paragraph2Editor = driver.findElement(By.xpath(getParagraphXPath(2) + "//textarea"));
    paragraph2Editor.sendKeys("z.angularBind" + Keys.chord(Keys.SHIFT, "9") + "\"myVar\", 1)");
    paragraph2Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER));
    waitForParagraph(2, "FINISHED");

    // check expected text
    assertEquals("BindingTest_1_",
            driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).getText());

    /*
     * print variable
     * print("myVar="+z.angular("myVar"))
     */
    WebElement paragraph3Editor = driver.findElement(By.xpath(getParagraphXPath(3) + "//textarea"));
    paragraph3Editor.sendKeys("print" + Keys.chord(Keys.SHIFT, "9") + "\"myVar=\"" + Keys.chord(Keys.ADD)
            + "z.angular" + Keys.chord(Keys.SHIFT, "9") + "\"myVar\"))");
    paragraph3Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER));
    waitForParagraph(3, "FINISHED");

    // check expected text
    assertEquals("myVar=1",
            driver.findElement(By.xpath(getParagraphXPath(3) + "//div[@ng-bind=\"paragraph.result.msg\"]"))
                    .getText());

    /*
     * Click element
     */
    driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).click();

    // check expected text
    assertEquals("BindingTest_2_",
            driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).getText());

    /*
     * Register watcher
     * z.angularWatch("myVar", (before:Object, after:Object, context:org.apache.zeppelin.interpreter.InterpreterContext) => {
     *   z.run(2, context)
     * }
     */
    WebElement paragraph4Editor = driver.findElement(By.xpath(getParagraphXPath(4) + "//textarea"));
    paragraph4Editor.sendKeys(
            "z.angularWatch" + Keys.chord(Keys.SHIFT, "9") + "\"myVar\", " + Keys.chord(Keys.SHIFT, "9")
                    + "before:Object, after:Object, context:org.apache.zeppelin.interpreter.InterpreterContext)"
                    + Keys.EQUALS + ">{ z.run" + Keys.chord(Keys.SHIFT, "9") + "2, context)}");
    paragraph4Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER));
    waitForParagraph(4, "FINISHED");

    /*
     * Click element, again and see watcher works
     */
    driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).click();

    // check expected text
    assertEquals("BindingTest_3_",
            driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).getText());
    waitForParagraph(3, "FINISHED");

    // check expected text by watcher
    assertEquals("myVar=3",
            driver.findElement(By.xpath(getParagraphXPath(3) + "//div[@ng-bind=\"paragraph.result.msg\"]"))
                    .getText());

    /*
     * Unbind
     * z.angularUnbind("myVar")
     */
    WebElement paragraph5Editor = driver.findElement(By.xpath(getParagraphXPath(5) + "//textarea"));
    paragraph5Editor.sendKeys("z.angularUnbind" + Keys.chord(Keys.SHIFT, "9") + "\"myVar\")");
    paragraph5Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER));
    waitForParagraph(5, "FINISHED");

    // check expected text
    assertEquals("BindingTest__",
            driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).getText());

    /*
     * Bind again and see rebind works.
     */
    paragraph2Editor = driver.findElement(By.xpath(getParagraphXPath(2) + "//textarea"));
    paragraph2Editor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER));
    waitForParagraph(2, "FINISHED");

    // check expected text
    assertEquals("BindingTest_1_",
            driver.findElement(By.xpath(getParagraphXPath(1) + "//div[@id=\"angularTestButton\"]")).getText());

    System.out.println("testCreateNotebook Test executed");
}

From source file:org.auraframework.components.ui.tooltip.TooltipUiTest.java

License:Apache License

/**
 * If tooltip is triggered by click then it should open and close by
 * pressing enter on keyboard/*w  ww.j a v  a  2 s.co m*/
 */
public void testToolTipOpenAndCloseWithEnterKey() throws Exception {
    open(URL_FULL_CMP);
    WebElement trigger = findDomElement(By.cssSelector(".triggerClick"));

    // click on element to gain focus and verify tooltip opens
    trigger.click();
    waitForToolTipPresent();

    // close by sending enter key
    trigger.sendKeys(Keys.ENTER);
    waitForToolTipAbsent();

    // open by sending enter key
    trigger.sendKeys(Keys.ENTER);
    waitForToolTipPresent();
}

From source file:org.auraframework.integration.test.components.ui.inlineEditGrid.InlineEditGridUITest.java

License:Apache License

@Test
public void testEnterEditCell() throws Exception {
    open(inlineURL);//from   w w  w .j  av a2s. c  om
    WebDriver driver = getDriver();
    switchKeyboardMode(driver);
    pressKey(driver, Keys.ARROW_RIGHT);
    pressKey(driver, EDIT_TRIGGER_SELECTOR, Keys.ENTER);
    assertNotNull(driver.findElement(By.cssSelector(INPUT_PANEL_SELECTOR)));
}

From source file:org.auraframework.integration.test.components.ui.inlineEditGrid.InlineEditGridUITest.java

License:Apache License

private void verifyKeypressEventOnEditPanel(Keys keyPress) throws MalformedURLException, URISyntaxException {
    open(inlineURL);//from www  . j  av  a  2 s.  c  om
    WebDriver driver = getDriver();
    switchKeyboardMode(driver);
    pressKey(driver, Keys.TAB);

    // open edit on cell
    pressKey(driver, EDIT_TRIGGER_SELECTOR, Keys.ENTER);
    waitForEditPanelOpen(driver);
    editPanelContent(driver, "abc");

    if (keyPress.equals(Keys.TAB)) {
        // tab out to close
        pressKey(driver, INPUT_PANEL_INPUT_SELECTOR, keyPress);
    } else {
        // shift tab out to close
        driver.findElement(By.cssSelector(INPUT_PANEL_INPUT_SELECTOR)).sendKeys(Keys.SHIFT, Keys.TAB);
    }

    waitForEditPanelClose(driver);

    verifyCellContent(driver, 0, 1, "abc");

}

From source file:org.auraframework.integration.test.components.ui.inlineEditGrid.InlineEditGridUITest.java

License:Apache License

/**
  * Test click out of panel//from www  . j  a v a 2 s.  c om
  */
@Test
public void testClickOutOfEditPanel() throws Exception {
    open(inlineURL);
    WebDriver driver = getDriver();
    switchKeyboardMode(driver);
    pressKey(driver, Keys.TAB);

    // open edit on cell
    pressKey(driver, EDIT_TRIGGER_SELECTOR, Keys.ENTER);
    waitForEditPanelOpen(driver);
    editPanelContent(driver, "abc");

    // click out to close
    WebElement input = driver.findElement(By.cssSelector(INPUT_TXT_SELECTOR));
    input.click();
    waitForEditPanelClose(driver);

    verifyCellContent(driver, 0, 1, "abc");
}

From source file:org.auraframework.integration.test.components.ui.inputDate.InputDateWithLabelUITest.java

License:Apache License

private String homeEndButtonHelper(String initDate, Keys buttonToPress) {
    // Getting the input box, making sure it is clear, and sending in the the starting date
    WebElement element = findDomElement(By.cssSelector(DATE_INPUT_BOX_SEL));
    element.clear();/*from   w w  w .j a v  a  2 s .  c  o m*/
    element.sendKeys(initDate);

    // Opening the calendar icon to grab the date we are looking for
    openDatePicker();

    // Grabbing the correct focus cell date
    By selectedDate = By.cssSelector(SELECTED_DATE);
    element = findDomElement(selectedDate);

    // Pressing the home or End button and grabbing the associated date
    element.sendKeys(buttonToPress);

    // Clicking on that element to compare it to the date we should receive
    element = (WebElement) getAuraUITestingUtil().getEval(ACTIVE_ELEMENT);
    element.sendKeys(Keys.ENTER);

    // Repointing to the InputTextBox
    element = findDomElement(By.cssSelector(DATE_INPUT_BOX_SEL));

    // Making sure they are equal
    return element.getAttribute("value");
}

From source file:org.auraframework.integration.test.components.ui.inputDate.InputDateWithLabelUITest.java

License:Apache License

/**
 * Test Flow://  ww w .ja v a  2 s. co m
 * 1. Have focus on inputDate
 * 2. Tab onto the calendar icon and press enter
 * 3. After datepicker opens, press a button (ESC, ENTER, SPACE) to close it
 * 4. Check if inputDate has focus
 * @throws Exception
 */
// Testing the focus after closing datePicker
// Disabling for Safari since Safari does not handle tabs normally
@ExcludeBrowsers({ BrowserType.SAFARI, BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET, BrowserType.IPAD,
        BrowserType.IPHONE })

@Test
public void testFocusOnClosingDP() throws Exception {

    // the different keys we will use to close the datePicker
    Keys[] keysToClose = { Keys.ESCAPE, Keys.ENTER, Keys.SPACE };

    open(URL);

    for (int i = 0; i < keysToClose.length; i++) {

        WebElement inputDate = findDomElement(By.cssSelector(DATE_INPUT_BOX_SEL));
        inputDate.sendKeys(Keys.TAB);

        //active element should now be the calendar icon - hit enter to open datePicker
        WebElement activeElement = (WebElement) getAuraUITestingUtil().getEval(ACTIVE_ELEMENT);
        activeElement.sendKeys(Keys.ENTER);

        //datePicker should be open
        getAuraUITestingUtil().waitForElement("datePicker should been present, but its not",
                By.cssSelector(".uiDatePicker.visible"));

        //use key to close the datePicker
        WebElement selectedDate = findDomElement(By.cssSelector(SELECTED_DATE));
        selectedDate.sendKeys(keysToClose[i]);

        //check if datePicker is closed
        getAuraUITestingUtil().waitForElementNotPresent("datePicker should not be present, but it is",
                By.cssSelector(".uiDatePicker.visible"));

        //check if active element is the inputDate
        activeElement = (WebElement) getAuraUITestingUtil().getEval(ACTIVE_ELEMENT);
        assertEquals("Focus not on the right element", activeElement, inputDate);

    }
}