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:org.auraframework.integration.test.components.ui.inlineEditGrid.InlineEditGridUITest.java

License:Apache License

/**
 * Test shift-tab out of edit panel.
 */
@Test
public void testShiftTabOutOfEditPanel() throws Exception {
    verifyKeypressEventOnEditPanel(Keys.SHIFT);
}

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);//w  w  w  .java2s.c  o m
    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.inputDate.InputDateWithLabelUITest.java

License:Apache License

@ExcludeBrowsers({ BrowserType.IE7, BrowserType.IE9, BrowserType.IE10, BrowserType.IE11,
        BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE })
@Test/*from  ww  w . ja va2s.c o  m*/
public void testPageUpDownYear() throws Exception {
    DateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STR);
    open(URL);
    // 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.trim());

    // 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.trim());
}

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

License:Apache License

@UnAdaptableTest
// Checking functionality of the shift tab button
// temporarily disabled due to a bug in the initial positioning. Will re-enable once that issue is fixed
@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  w w  w . j a  v a2  s  . c o m

    WebDriver driver = getDriver();

    // Getting input textbox in focus
    WebElement element = findDomElement(By.cssSelector(DATE_INPUT_BOX_SEL));
    element.click();
    element.sendKeys("20151111");
    getAuraUITestingUtil().pressTab(element);

    String classOfActiveElem = "a[class*='" + getAuraUITestingUtil().getEval(CLASSNAME) + "']";
    element = findDomElement(By.cssSelector(classOfActiveElem));
    String elementClass = element.getAttribute("class");
    assertTrue("Tabbing did not take us to the date picker icon",
            elementClass.indexOf("datePicker-openIcon") >= 0);
    element.click();

    // Focused on Today's date
    classOfActiveElem = "td[class*='" + getAuraUITestingUtil().getEval(CLASSNAME) + "']";
    element = findDomElement(By.cssSelector(classOfActiveElem));
    elementClass = element.getAttribute("class");
    assertTrue("Tabbing did not take us to the selected date", elementClass.indexOf("selectedDate") >= 0);
    getAuraUITestingUtil().pressTab(element);

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

    // 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*='" + getAuraUITestingUtil().getEval(CLASSNAME) + "']";
    element = findDomElement(By.cssSelector(classOfActiveElem));

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

From source file:org.auraframework.integration.test.localization.LocalizationAppUITest.java

License:Apache License

@ExcludeBrowsers({ BrowserType.IE9, BrowserType.IE10, BrowserType.SAFARI, BrowserType.ANDROID_PHONE,
        BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE })
// Checking functionality of the inputPercent/outputPercent components
@Test//from   w w w  .j  av a  2  s.c  o m
public void testPercentComponents() throws Exception {
    open(URL);

    // initial load
    By outputSelector = By.cssSelector("span[class~='uiOutputPercent']");
    WebElement elementInput = findDomElement(By.cssSelector("input[class~='uiInputPercent']"));
    WebElement elementoutput = findDomElement(outputSelector);
    assertEquals("InputPercent component rendered with wrong value", "1,235%",
            elementInput.getAttribute("value"));
    assertEquals("outputPercent component rendered with wrong value", "1,235%", elementoutput.getText());

    // Tab out
    elementInput.click();
    elementInput.sendKeys(Keys.HOME, Keys.chord(Keys.SHIFT, Keys.END));
    elementInput.sendKeys("22.35");
    getAuraUITestingUtil().pressTab(elementInput);

    getAuraUITestingUtil().waitForElementText(outputSelector, "22%", true,
            "outputPercent component rendered with wrong value");
    assertEquals("InputPercent component rendered with wrong value", "22%", elementInput.getAttribute("value"));

    // Submit click
    elementInput.click();
    elementInput.sendKeys(Keys.HOME, Keys.chord(Keys.SHIFT, Keys.END));
    elementInput.sendKeys("1.2235");
    WebElement elementButton = findDomElement(By.cssSelector("button[title~='Percent']"));
    elementButton.click();

    getAuraUITestingUtil().waitForElementText(outputSelector, "1%", true,
            "outputPercent component rendered with wrong value");
    assertEquals("InputPercent component rendered with wrong value", "1%", elementInput.getAttribute("value"));
}

From source file:org.auraframework.integration.test.localization.LocalizationAppUITest.java

License:Apache License

@ExcludeBrowsers({ BrowserType.IE9, BrowserType.IE10, BrowserType.SAFARI, BrowserType.ANDROID_PHONE,
        BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE })
// Checking functionality of the inputCurrency/outputCurrency components
@Test/*w  w  w.  j  a  v a2  s  .c  o  m*/
public void testCurrencyComponents() throws Exception {
    open(URL);

    // initial load
    By outputSelector = By.cssSelector("span[class~='uiOutputCurrency']");
    WebElement elementInput = findDomElement(By.cssSelector("span[id='MyCurrency'] > input[class~='uiInput']"));
    WebElement elementOutput = findDomElement(outputSelector);
    assertEquals("InputCurrency component rendered with wrong value", "$123,456.79",
            elementInput.getAttribute("value"));
    assertEquals("outputCurrency component rendered with wrong value", "$123,456.79", elementOutput.getText());

    // Tab out
    elementInput.click();
    elementInput.sendKeys(Keys.HOME, Keys.chord(Keys.SHIFT, Keys.END));
    elementInput.sendKeys("123456");
    getAuraUITestingUtil().pressTab(elementInput);

    getAuraUITestingUtil().waitForElementText(outputSelector, "$123,456.00", true,
            "OutputCurrency component rendered with wrong value");
    assertEquals("InputCurrency component rendered with wrong value", "$123,456.00",
            elementInput.getAttribute("value"));

    // Submit click
    elementInput.click();
    elementInput.sendKeys(Keys.HOME, Keys.chord(Keys.SHIFT, Keys.END));
    elementInput.sendKeys("123.45");
    WebElement elementButton = findDomElement(By.cssSelector("button[title~='Currency']"));
    elementButton.click();

    getAuraUITestingUtil().waitForElementText(outputSelector, "$123.45", true,
            "OutputCurrency component rendered with wrong value");
    assertEquals("InputCurrency component rendered with wrong value", "$123.45",
            elementInput.getAttribute("value"));
}

From source file:org.auraframework.integration.test.util.WebDriverTestCase.java

License:Apache License

public Action shiftTab() {
    Actions builder = new Actions(getDriver());
    builder.keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyUp(Keys.SHIFT);
    return builder.build();
}

From source file:org.auraframework.test.util.WebDriverTestCase.java

License:Apache License

public Action shiftTab() {
    Actions builder = new Actions(currentDriver);
    builder.keyDown(Keys.SHIFT).sendKeys(Keys.TAB).keyUp(Keys.SHIFT);
    return builder.build();
}

From source file:org.callimachusproject.webdriver.helpers.WebBrowserDriver.java

License:Apache License

private void sendKeys(WebElement element, CharSequence... keys) {
    StringBuilder sb = new StringBuilder();
    List<CharSequence> list = new ArrayList<CharSequence>(keys.length * 2);
    for (CharSequence key : keys) {
        if (key instanceof String) {
            for (char chr : ((String) key).toCharArray()) {
                switch (chr) {
                case '-':
                    sendKeys(element, list, sb);
                    list.add(Keys.SUBTRACT);
                    break;
                case '!':
                    sendKeys(element, list, sb);
                    list.add(Keys.chord(Keys.SHIFT, "1"));
                    break;
                case '@':
                    sendKeys(element, list, sb);
                    list.add(Keys.chord(Keys.SHIFT, "2"));
                    break;
                case '#':
                    sendKeys(element, list, sb);
                    list.add(Keys.chord(Keys.SHIFT, "3"));
                    break;
                case '$':
                    sendKeys(element, list, sb);
                    list.add(Keys.chord(Keys.SHIFT, "4"));
                    break;
                case '%':
                    sendKeys(element, list, sb);
                    list.add(Keys.chord(Keys.SHIFT, "5"));
                    break;
                case '^':
                    sendKeys(element, list, sb);
                    list.add(Keys.chord(Keys.SHIFT, "6"));
                    break;
                case '&':
                    sendKeys(element, list, sb);
                    list.add(Keys.chord(Keys.SHIFT, "7"));
                    break;
                case '*':
                    sendKeys(element, list, sb);
                    list.add(Keys.chord(Keys.SHIFT, "8"));
                    break;
                case '(':
                    sendKeys(element, list, sb);
                    list.add(Keys.chord(Keys.SHIFT, "9"));
                    break;
                case ')':
                    sendKeys(element, list, sb);
                    list.add(Keys.chord(Keys.SHIFT, "0"));
                    break;
                case '{':
                case '}':
                case '<':
                case '>':
                case '[':
                case ']':
                case '"':
                case '\'':
                case '\n':
                    sendKeys(element, list, sb);
                    sb.append(chr);/*from   w w  w .  ja  v a2  s . co m*/
                    sendKeys(element, list, sb);
                    break;
                default:
                    sb.append(chr);
                }
            }
        } else {
            list.add(key);
        }
    }
    sendKeys(element, list, sb);
}

From source file:org.eclipse.che.selenium.debugger.StepIntoStepOverStepReturnWithChangeVariableTest.java

License:Open Source License

@Test(priority = 1)
public void shouldOpenDebuggingFile() {
    buildProjectAndOpenMainClass();/*from  ww  w  .  ja  v a2  s .c om*/
    commandsPalette.openCommandPalette();
    commandsPalette.startCommandByDoubleClick(START_DEBUG);
    consoles.waitExpectedTextIntoConsole(" Server startup in");
    editor.setInactiveBreakpoint(26);
    seleniumWebDriver.switchTo().activeElement().sendKeys(Keys.SHIFT.toString() + Keys.F9.toString());
    editor.waitAcitveBreakpoint(26);
}