Example usage for org.openqa.selenium Keys END

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

Introduction

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

Prototype

Keys END

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

Click Source Link

Usage

From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridEditorBufferedTest.java

License:Apache License

@Test
public void testProgrammaticSave() {
    selectMenuPath(EDIT_ITEM_100);/*from w  ww. j a v  a2s.co m*/

    WebElement textField = getEditorWidgets().get(0);

    textField.click();
    // without this, the click in the middle of the field might not be after
    // the old text on some browsers
    new Actions(getDriver()).sendKeys(Keys.END).perform();

    textField.sendKeys(" changed");

    selectMenuPath("Component", "Editor", "Save");

    assertEquals("(100, 0) changed", getGridElement().getCell(100, 0).getText());
}

From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridKeyboardNavigationTest.java

License:Apache License

@Test
public void testHomeEnd() throws Exception {
    openTestURL();//from   w ww.  j  a va  2  s . c o m

    getGridElement().getCell(100, 2).click();

    new Actions(getDriver()).sendKeys(Keys.HOME).perform();
    assertTrue("First row is not visible", getGridElement().getCell(0, 2).isDisplayed());

    new Actions(getDriver()).sendKeys(Keys.END).perform();
    assertTrue("Last row cell not visible",
            getGridElement().getCell(GridBasicFeatures.ROWS - 1, 2).isDisplayed());
}

From source file:org.aludratest.service.gui.web.selenium.selenium2.Selenium2Facade.java

License:Apache License

public void setValue(GUIElementLocator locator, String value) {
    WebElement element = findElement(locator);
    String id = element.getAttribute("id");
    String fieldType = element.getAttribute("type");
    boolean fallback = true;
    if (!DataMarkerCheck.isNull(id) || "file".equals(fieldType)) {
        executeScript("document.getElementById('" + id + "').setAttribute('value', '"
                + value.replace("'", "\\'") + "')");
        // validate success
        if (value.equals(element.getAttribute("value"))) {
            fallback = false;//from  w  w w  .ja  va 2s .  com
            executeScript(FIRE_ONCHANGE_SCRIPT, element);
        }
    }

    // fallback code
    if (fallback) {
        element.sendKeys(Keys.END);
        String text;
        while (!DataMarkerCheck.isNull(text = element.getAttribute("value"))) {
            int length = text.length();
            String[] arr = new String[length];
            for (int i = 0; i < length; i++) {
                arr[i] = "\b";
            }
            element.sendKeys(arr);
        }
        element.sendKeys(value);
    }
}

From source file:org.aludratest.service.gui.web.selenium.selenium2.Selenium2Wrapper.java

License:Apache License

private void setValue(WebElement element, String value) {
    LOGGER.debug("setValue(WebElement, {})", value);
    sendKeys(element, Keys.END);
    String text;//from  www.  j a  v  a 2s .c  om
    int tryCounter = 3;
    while (tryCounter > 0 && !DataMarkerCheck.isNull(text = getValue(element))) {
        int length = text.length();
        String[] arr = new String[length];
        for (int i = 0; i < length; i++) {
            arr[i] = "\b";
        }
        sendKeys(element, arr);
        tryCounter--;
    }
    if (tryCounter == 0) {
        throw new AutomationException("Could not clear input field. Maybe covered by other component?");
    }
    sendKeys(element, value);

    try {
        sendKeys(element, Keys.TAB);
    } catch (StaleElementReferenceException e) {
        // ignore; key could have caused page change
        LOGGER.debug("Could not fire change event for element because element is now stale.");
    } catch (WebDriverException e) {
        // of course, PhantomJS does NOT throw a StaleElementReferenceException, but some evil error...
        if (e.getMessage() != null && e.getMessage().matches("(?s).*'?undefined'? is not a .*")) {
            LOGGER.debug("Could not fire change event for element because element is now stale.");
        } else {
            throw e;
        }
    }
}

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

License:Apache License

/***********************************************************************************************
 *********************************** Date Picker Tests*******************************************
 ***********************************************************************************************/
// Home and End Button Test using January (31 days) , February (28 or 29 days), September (30 days)
@ExcludeBrowsers({ BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET, BrowserType.IPAD,
        BrowserType.IPHONE })//  w w w  . jav a  2s  .  c o  m
public void testHomeEnd() throws Exception {
    open(URL);

    // Checking January (31 days)
    String inputBoxResult = homeEndButtonHelper("2011-1-31", Keys.HOME);
    assertEquals("The Home button did not go to the beginning of January", "2011-01-01", inputBoxResult);

    inputBoxResult = homeEndButtonHelper("2011-1-1", Keys.END);
    assertEquals("The End button did not go to the end of January", "2011-01-31", inputBoxResult);

    // Checking February (28 or 29 days), none Leap year
    inputBoxResult = homeEndButtonHelper("2011-2-28", Keys.HOME);
    assertEquals("The Home button did not go to the beginning of February", "2011-02-01", inputBoxResult);

    inputBoxResult = homeEndButtonHelper("2011-2-1", Keys.END);
    assertEquals("The End button did not go to the end of February", "2011-02-28", inputBoxResult);

    // Checking February (28 or 29 days), Leap year
    inputBoxResult = homeEndButtonHelper("2012-2-29", Keys.HOME);
    assertEquals("The Home button did not go to the beginning of February", "2012-02-01", inputBoxResult);

    inputBoxResult = homeEndButtonHelper("2012-2-1", Keys.END);
    assertEquals("The End button did not go to the end of February", "2012-02-29", inputBoxResult);

    // Checking September (30 days)
    inputBoxResult = homeEndButtonHelper("2011-9-30", Keys.HOME);
    assertEquals("The Home button did not go to the beginning of September", "2011-09-01", inputBoxResult);

    inputBoxResult = homeEndButtonHelper("2011-9-1", Keys.END);
    assertEquals("The End button did not go to thes end of September", "2011-09-30", inputBoxResult);
}

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

License:Apache License

/***********************************************************************************************
 *********************************** Date Picker Tests*******************************************
 ***********************************************************************************************/
// Home and End Button Test using January (31 days) , February (28 or 29 days), September (30 days)
@ExcludeBrowsers({ BrowserType.IE7, BrowserType.IE8, BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET,
        BrowserType.IPAD, BrowserType.IPHONE })
public void testHomeEnd() throws Exception {
    open(URL);/*from  w ww  .j a va2  s .com*/

    // Checking January (31 days)
    String inputBoxResult = homeEndButtonHelper("2011-1-31", Keys.HOME);
    assertEquals("The Home button did not go to the beginning of January", "2011-01-01", inputBoxResult);

    inputBoxResult = homeEndButtonHelper("2011-1-1", Keys.END);
    assertEquals("The End button did not go to the end of January", "2011-01-31", inputBoxResult);

    // Checking February (28 or 29 days), none Leap year
    inputBoxResult = homeEndButtonHelper("2011-2-28", Keys.HOME);
    assertEquals("The Home button did not go to the beginning of February", "2011-02-01", inputBoxResult);

    inputBoxResult = homeEndButtonHelper("2011-2-1", Keys.END);
    assertEquals("The End button did not go to the end of February", "2011-02-28", inputBoxResult);

    // Checking February (28 or 29 days), Leap year
    inputBoxResult = homeEndButtonHelper("2012-2-29", Keys.HOME);
    assertEquals("The Home button did not go to the beginning of February", "2012-02-01", inputBoxResult);

    inputBoxResult = homeEndButtonHelper("2012-2-1", Keys.END);
    assertEquals("The End button did not go to the end of February", "2012-02-29", inputBoxResult);

    // Checking September (30 days)
    inputBoxResult = homeEndButtonHelper("2011-9-30", Keys.HOME);
    assertEquals("The Home button did not go to the beginning of September", "2011-09-01", inputBoxResult);

    inputBoxResult = homeEndButtonHelper("2011-9-1", Keys.END);
    assertEquals("The End button did not go to thes end of September", "2011-09-30", inputBoxResult);
}

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

License:Apache License

/***********************************************************************************************
 *********************************** Date Picker Tests*******************************************
 ***********************************************************************************************/
// Home and End Button Test using January (31 days) , February (28 or 29 days), September (30 days)
@ExcludeBrowsers({ BrowserType.IE7, BrowserType.IE8, BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET,
        BrowserType.IPAD, BrowserType.IPHONE })
@Test/*from w  w  w  .ja v a2s  .c o m*/
public void testHomeEnd() throws Exception {
    open(URL);

    // Checking January (31 days)
    String inputBoxResult = homeEndButtonHelper("2011-1-31", Keys.HOME);
    assertEquals("The Home button did not go to the beginning of January", "2011-01-01", inputBoxResult.trim());

    inputBoxResult = homeEndButtonHelper("2011-1-1", Keys.END);
    assertEquals("The End button did not go to the end of January", "2011-01-31", inputBoxResult.trim());

    // Checking February (28 or 29 days), none Leap year
    inputBoxResult = homeEndButtonHelper("2011-2-28", Keys.HOME);
    assertEquals("The Home button did not go to the beginning of February", "2011-02-01",
            inputBoxResult.trim());

    inputBoxResult = homeEndButtonHelper("2011-2-1", Keys.END);
    assertEquals("The End button did not go to the end of February", "2011-02-28", inputBoxResult.trim());

    // Checking February (28 or 29 days), Leap year
    inputBoxResult = homeEndButtonHelper("2012-2-29", Keys.HOME);
    assertEquals("The Home button did not go to the beginning of February", "2012-02-01",
            inputBoxResult.trim());

    inputBoxResult = homeEndButtonHelper("2012-2-1", Keys.END);
    assertEquals("The End button did not go to the end of February", "2012-02-29", inputBoxResult.trim());

    // Checking September (30 days)
    inputBoxResult = homeEndButtonHelper("2011-9-30", Keys.HOME);
    assertEquals("The Home button did not go to the beginning of September", "2011-09-01",
            inputBoxResult.trim());

    inputBoxResult = homeEndButtonHelper("2011-9-1", Keys.END);
    assertEquals("The End button did not go to thes end of September", "2011-09-30", inputBoxResult.trim());
}

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  a  v  a 2  s . co  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//from   w  w w .  j  av  a 2  s  . c om
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.callimachusproject.webdriver.pages.DocEditor.java

License:Apache License

public DocEditor end() {
    browser.focusInFrameIndex(0, 0);
    browser.sendKeys(Keys.END);
    browser.sendKeys(Keys.ARROW_RIGHT);
    return this;
}