Example usage for org.openqa.selenium Keys SHIFT

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

Introduction

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

Prototype

Keys SHIFT

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

Click Source Link

Usage

From source file:info.magnolia.integrationtests.uitest.KeyboardShortcutUITest.java

License:Open Source License

@Test
public void focusIsNotLostIfThereIsNotAnotherItemToEdit() throws Exception {
    // GIVEN// w  w w  .j  a va 2 s . c  o  m
    getAppIcon("Configuration").click();
    waitUntil(appIsLoaded());
    assertAppOpen("Configuration");

    getTreeTableItem("server").click();

    // WHEN
    getKeyboard().pressKey(Keys.chord(Keys.SHIFT, Keys.TAB));
    delay(1, "Wait for key press");

    // THEN
    // make sure server node is still selected
    assertTrue(isTreeTableItemSelected("server"));

    // WHEN
    getKeyboard().pressKey(Keys.ENTER);
    delay(1, "Wait for key press");

    // THEN
    // check if we're in inline editing mode
    assertThat(getEditedElement().getTagName(), is("input"));
}

From source file:info.magnolia.integrationtests.uitest.KeyboardShortcutUITest.java

License:Open Source License

@Test
public void selectionIsOnCorrectRowWhenCyclingUsingTab() throws Exception {
    // GIVEN/*from   ww  w  .j  ava  2 s.com*/
    getAppIcon("Configuration").click();
    waitUntil(appIsLoaded());
    assertAppOpen("Configuration");

    getTreeTableItemExpander("server").click();
    getTreeTableItem("server").click();
    getTreeTableItem("admin").click();

    // WHEN
    // edit admin property and cycle 3 times using tab
    getKeyboard().pressKey(Keys.ENTER);
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.TAB);
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.TAB);
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.TAB);
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.ENTER);

    // THEN
    assertTrue(isTreeTableItemSelected("defaultBaseUrl"));

    // WHEN
    // now cycle back to admin property
    getKeyboard().pressKey(Keys.ENTER);
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.chord(Keys.SHIFT, Keys.TAB));
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.chord(Keys.SHIFT, Keys.TAB));
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.chord(Keys.SHIFT, Keys.TAB));
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.ENTER);
    delay(1, "Wait for key press");

    // THEN
    assertTrue(isTreeTableItemSelected("admin"));
}

From source file:info.magnolia.integrationtests.uitest.KeyboardShortcutUITest.java

License:Open Source License

@Test
public void itIsPossibleToCycleBetweenPropertiesAndNodes() throws Exception {
    // GIVEN//from  ww w. j  a  v a2s  .  co m
    getAppIcon("Configuration").click();
    waitUntil(appIsLoaded());
    assertAppOpen("Configuration");

    getTreeTableItemExpander("server").click();
    delay(1, "Wait so item gets expanded");
    getTreeTableItem("server").click();
    delay(1, "Wait for item to be selected");
    getTreeTableItem("admin").click();
    delay(1, "Wait for item to be selected");

    // WHEN
    // cycle back to auditLogging node
    getKeyboard().pressKey(Keys.ENTER);
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.chord(Keys.SHIFT, Keys.TAB));
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.chord(Keys.SHIFT, Keys.TAB));
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.chord(Keys.SHIFT, Keys.TAB));
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.ENTER);
    delay(1, "Wait for key press");

    // THEN
    assertTrue(isTreeTableItemSelected("auditLogging"));

    // WHEN
    // now cycle back to admin property
    getKeyboard().pressKey(Keys.ENTER);
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.TAB);
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.TAB);
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.TAB);
    delay(1, "Wait for key press");
    getKeyboard().pressKey(Keys.ENTER);
    delay(1, "Wait for key press");

    // THEN
    assertTrue(isTreeTableItemSelected("admin"));
}

From source file:io.github.blindio.prospero.core.browserdrivers.WebDriverDriver.java

License:Apache License

public void shiftClick(String locator) {
    WebElement element = getWebDriver().findElement(BySeleneseLocator.seleneseLocator(locator));
    Actions builder = new Actions(getWebDriver());
    builder.keyDown(Keys.SHIFT).click(element).keyUp(Keys.SHIFT).build().perform();
}

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

License:Apache License

public void testEditOnDoubleClick() throws Exception {
    try {/*  w ww . jav  a2  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.ZeppelinIT.java

License:Apache License

@Test
public void testAngularDisplay() throws InterruptedException {
    if (!endToEndTestEnabled()) {
        return;//from w w w . j  a va 2 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.inputDate.BaseInputDateUITester.java

License:Apache License

@ExcludeBrowsers({ BrowserType.IE9, BrowserType.IE10, BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET,
        BrowserType.IPAD, BrowserType.IPHONE })
public void testPageUpDownYear() throws Exception {
    DateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STR);
    open(URL);/*from ww  w.j a v a  2 s. c  om*/
    // Calendar used to get current date
    GregorianCalendar cal = new GregorianCalendar();
    // Running test, Increasing year
    String result = pageUpDownHelper(10, Keys.SHIFT + "" + Keys.PAGE_UP);

    // Moving calendar to match corresponding action of test and formatting date
    cal.setTime(formatter.parse(TEST_DATE_TO_USE));
    cal.add(Calendar.YEAR, -10);

    // Formatting date to match out of test
    String fmt = new SimpleDateFormat(DATE_FORMAT_STR).format(cal.getTime());

    // Making sure test result and true calendar outcome match
    assertEquals("Shift + Page up did not go to the correct date", fmt, result);

    // Resetting calendar
    cal = new GregorianCalendar();

    // Running test, decreasing month
    result = pageUpDownHelper(15, Keys.SHIFT + "" + Keys.PAGE_DOWN);

    // Moving calendar to match corresponding action of test and formatting date
    cal.setTime(formatter.parse(TEST_DATE_TO_USE));
    cal.add(Calendar.YEAR, 15);
    fmt = new SimpleDateFormat(DATE_FORMAT_STR).format(cal.getTime());

    // Making sure test result and true calendar outcome match
    assertEquals("shift + Page Down did not find the correct date", fmt, result);
}

From source file:org.auraframework.components.ui.inputDate.BaseInputDateUITester.java

License:Apache License

@ExcludeBrowsers({ BrowserType.IE9, BrowserType.IE10, BrowserType.SAFARI, BrowserType.ANDROID_PHONE,
        BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE })
public void testShiftTab() throws Exception {
    open(URL);/*from  ww  w.j  ava2 s . c o  m*/

    WebDriver driver = getDriver();

    // Tab test Begins
    // Getting input textbox in focus
    WebElement element = findDomElement(By.cssSelector(DATE_INPUT_BOX_SEL));
    element.click();
    element.sendKeys("11111111");
    auraUITestingUtil.pressTab(element);

    String classOfActiveElem = "a[class*='" + auraUITestingUtil.getEval(CLASSNAME) + "']";
    element = findDomElement(By.cssSelector(classOfActiveElem));
    element.click();

    // Focused on Today's date, grabbing it and pressing tab to go to the Today hyperlink
    classOfActiveElem = "a[class*='" + auraUITestingUtil.getEval(CLASSNAME) + "']";
    element = findDomElement(By.cssSelector(classOfActiveElem));
    auraUITestingUtil.pressTab(element);

    String shftTab = Keys.SHIFT + "" + Keys.TAB;

    // Going from Today hyperlink, back to SELECTED_DATE
    gotToNextElem(driver, shftTab);

    // Going from SELECTED_DATE to next-year
    gotToNextElem(driver, shftTab);

    // Going from next-year to next-month
    gotToNextElem(driver, shftTab);

    // Going from next-month to prev-month
    gotToNextElem(driver, shftTab);

    // Going from prev-month to prev-Year
    gotToNextElem(driver, shftTab);

    // Going from prev-Year to icon
    gotToNextElem(driver, shftTab);

    // Going from icon to input box
    gotToNextElem(driver, shftTab);

    // Getting the input textbox in focus and getting the value, which should not have changed
    classOfActiveElem = "input[class*='" + auraUITestingUtil.getEval(CLASSNAME) + "']";
    element = findDomElement(By.cssSelector(classOfActiveElem));

    assertEquals("Shift Tabbing did not get us to the input textbox", "1111-11-11",
            element.getAttribute("value"));
}

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

License:Apache License

@ExcludeBrowsers({ BrowserType.IE7, BrowserType.IE9, BrowserType.IE10, BrowserType.ANDROID_PHONE,
        BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE })
public void testPageUpDownYear() throws Exception {
    DateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STR);
    open(URL);/*from  www .j a va 2 s.c  o  m*/
    // Calendar used to get current date
    GregorianCalendar cal = new GregorianCalendar();
    // Running test, Increasing year
    String result = pageUpDownHelper(10, Keys.SHIFT + "" + Keys.PAGE_UP);

    // Moving calendar to match corresponding action of test and formatting date
    cal.setTime(formatter.parse(TEST_DATE_TO_USE));
    cal.add(Calendar.YEAR, -10);

    // Formatting date to match out of test
    String fmt = new SimpleDateFormat(DATE_FORMAT_STR).format(cal.getTime());

    // Making sure test result and true calendar outcome match
    assertEquals("Shift + Page up did not go to the correct date", fmt, result);

    // Resetting calendar
    cal = new GregorianCalendar();

    // Running test, decreasing month
    result = pageUpDownHelper(15, Keys.SHIFT + "" + Keys.PAGE_DOWN);

    // Moving calendar to match corresponding action of test and formatting date
    cal.setTime(formatter.parse(TEST_DATE_TO_USE));
    cal.add(Calendar.YEAR, 15);
    fmt = new SimpleDateFormat(DATE_FORMAT_STR).format(cal.getTime());

    // Making sure test result and true calendar outcome match
    assertEquals("shift + Page Down did not find the correct date", fmt, result);
}

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

License:Apache License

@UnAdaptableTest
// Checking functionality of the shift tab button
@ExcludeBrowsers({ BrowserType.IE9, BrowserType.IE10, BrowserType.SAFARI, BrowserType.ANDROID_PHONE,
        BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE })
public void testShiftTab() throws Exception {
    open(URL);/* w  w w  . j  ava 2  s . co  m*/

    WebDriver driver = getDriver();

    // Tab test Begins
    // Getting input textbox in focus
    WebElement element = findDomElement(By.cssSelector(DATE_INPUT_BOX_SEL));
    element.click();
    element.sendKeys("11111111");
    auraUITestingUtil.pressTab(element);

    String classOfActiveElem = "a[class*='" + auraUITestingUtil.getEval(CLASSNAME) + "']";
    element = findDomElement(By.cssSelector(classOfActiveElem));
    element.click();

    // Focused on Today's date, grabbing it and pressing tab to go to the Today hyperlink
    classOfActiveElem = "a[class*='" + auraUITestingUtil.getEval(CLASSNAME) + "']";
    element = findDomElement(By.cssSelector(classOfActiveElem));
    auraUITestingUtil.pressTab(element);

    String shftTab = Keys.SHIFT + "" + Keys.TAB;

    // Going from Today hyperlink, back to SELECTED_DATE
    // gotToNextElem(driver, shftTab);
    String classOfActiveElemButton = "button[class*='" + auraUITestingUtil.getEval(CLASSNAME) + "']";
    findDomElement(By.cssSelector(classOfActiveElemButton)).sendKeys(shftTab);

    // Going from SELECTED_DATE to next-year
    gotToNextElem(driver, shftTab);

    // Going from next-year to next-month
    gotToNextElem(driver, shftTab);

    // Going from next-month to prev-month
    gotToNextElem(driver, shftTab);

    // Going from prev-month to prev-Year
    gotToNextElem(driver, shftTab);

    // Going from prev-Year to icon
    gotToNextElem(driver, shftTab);

    // Going from icon to input box
    gotToNextElem(driver, shftTab);

    // Getting the input textbox in focus and getting the value, which should not have changed
    classOfActiveElem = "input[class*='" + auraUITestingUtil.getEval(CLASSNAME) + "']";
    element = findDomElement(By.cssSelector(classOfActiveElem));

    assertEquals("Shift Tabbing did not get us to the input textbox", "1111-11-11",
            element.getAttribute("value"));
}