Example usage for org.openqa.selenium Keys ARROW_LEFT

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

Introduction

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

Prototype

Keys ARROW_LEFT

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

Click Source Link

Usage

From source file:browsermator.com.LeftArrowKeyAction.java

@Override
public void RunAction(WebDriver driver) {
    try {/*from  w  w w . jav  a  2  s  . c  o  m*/
        WebElement element = driver.switchTo().activeElement();
        element.sendKeys(Keys.ARROW_LEFT);

        this.Pass = true;
    } catch (Exception ex) {
        this.Pass = false;
    }
}

From source file:com.gargoylesoftware.htmlunit.selenium.TypingTest.java

License:Apache License

/**
 * @throws Exception if an error occurs//from www . ja va 2 s.co m
 */
@Test
public void shouldBeAbleToUseArrowKeys() throws Exception {
    final WebDriver driver = getWebDriver("/javascriptPage.html");

    final WebElement keyReporter = driver.findElement(By.id("keyReporter"));
    keyReporter.sendKeys("tet", Keys.ARROW_LEFT, "s");

    assertThat(keyReporter.getAttribute("value"), is("test"));
}

From source file:com.gargoylesoftware.htmlunit.selenium.TypingTest.java

License:Apache License

/**
 * A test.//from www.  ja  va2  s  .  c  om
 */
@Test
public void shouldReportKeyCodeOfArrowKeys() {
    final WebDriver driver = getWebDriver("/javascriptPage.html");

    final WebElement result = driver.findElement(By.id("result"));
    final WebElement element = driver.findElement(By.id("keyReporter"));

    element.sendKeys(Keys.ARROW_DOWN);
    checkRecordedKeySequence(result, 40);

    element.sendKeys(Keys.ARROW_UP);
    checkRecordedKeySequence(result, 38);

    element.sendKeys(Keys.ARROW_LEFT);
    checkRecordedKeySequence(result, 37);

    element.sendKeys(Keys.ARROW_RIGHT);
    checkRecordedKeySequence(result, 39);

    // And leave no rubbish/printable keys in the "keyReporter"
    assertThat(element.getAttribute("value"), is(""));
}

From source file:com.gargoylesoftware.htmlunit.selenium.TypingTest.java

License:Apache License

/**
 * A test.//www  . jav a 2  s  .  c om
 */
@Test
public void shouldReportKeyCodeOfArrowKeysUpDownEvents() {
    final WebDriver driver = getWebDriver("/javascriptPage.html");

    final WebElement result = driver.findElement(By.id("result"));
    final WebElement element = driver.findElement(By.id("keyReporter"));

    element.sendKeys(Keys.ARROW_DOWN);
    assertThat(result.getText().trim(), containsString("down: 40"));
    assertThat(result.getText().trim(), containsString("up: 40"));

    element.sendKeys(Keys.ARROW_UP);
    assertThat(result.getText().trim(), containsString("down: 38"));
    assertThat(result.getText().trim(), containsString("up: 38"));

    element.sendKeys(Keys.ARROW_LEFT);
    assertThat(result.getText().trim(), containsString("down: 37"));
    assertThat(result.getText().trim(), containsString("up: 37"));

    element.sendKeys(Keys.ARROW_RIGHT);
    assertThat(result.getText().trim(), containsString("down: 39"));
    assertThat(result.getText().trim(), containsString("up: 39"));

    // And leave no rubbish/printable keys in the "keyReporter"
    assertThat(element.getAttribute("value"), is(""));
}

From source file:com.thoughtworks.selenium.webdriven.commands.TypeKeys.java

License:Apache License

@Override
protected Void handleSeleneseCommand(WebDriver driver, String locator, String value) {
    alertOverride.replaceAlertMethod(driver);

    value = value.replace("\\10", Keys.ENTER);
    value = value.replace("\\13", Keys.RETURN);
    value = value.replace("\\27", Keys.ESCAPE);
    value = value.replace("\\38", Keys.ARROW_UP);
    value = value.replace("\\40", Keys.ARROW_DOWN);
    value = value.replace("\\37", Keys.ARROW_LEFT);
    value = value.replace("\\39", Keys.ARROW_RIGHT);

    finder.findElement(driver, locator).sendKeys(value);

    return null;//  w ww .  j  ava2  s.  c om
}

From source file:com.thoughtworks.selenium.webdriven.commands.TypeKeysTest.java

License:Apache License

@Test
public void substitutesArrowKeys() {
    String expected = newString(Keys.ARROW_DOWN, Keys.ARROW_LEFT, Keys.ARROW_RIGHT, Keys.ARROW_UP);
    String input = "\\40\\37\\39\\38";

    new TypeKeys(new AlertOverrideStub(), elementFinder).apply(null, new String[] { "foo", input });

    verify(element).sendKeys(expected);/* w  ww .  j av  a2  s  .c om*/
}

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

License:Apache License

@Test
@Ignore/* ww  w. j a v a  2 s  .  c  o  m*/
public void testNavigationWithHiddenColumns_navigatingOverHiddenColumn_goesToNextVisibleColumn() {
    selectMenuPath("Component", "State", "Width", "1000px");
    toggleHideColumnAPI(2);
    toggleHideColumnAPI(3);
    assertColumnHeaderOrder(0, 1, 4, 5, 6);

    getGridElement().getCell(2, 4).click();
    GridCellElement cell = getGridElement().getCell(2, 4);
    assertTrue(cell.isFocused());

    new Actions(getDriver()).sendKeys(Keys.ARROW_LEFT);
    cell = getGridElement().getCell(2, 1);
    assertTrue(cell.isFocused());

    new Actions(getDriver()).sendKeys(Keys.ARROW_RIGHT);
    cell = getGridElement().getCell(2, 4);
    assertTrue(cell.isFocused());
}

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

License:Apache License

@Test
public void testNavigationWithHiddenColumns_hiddenFirstAndLastColumn_keepsNavigation() {
    selectMenuPath("Component", "State", "Width", "1000px");
    toggleHideColumnAPI(0);//from ww w . ja v  a2  s  .  com
    assertColumnHeaderOrder(1, 2, 3, 4, 5, 6);

    getGridElement().getCell(2, 1).click();
    assertTrue(getGridElement().getCell(2, 1).isFocused());

    new Actions(getDriver()).sendKeys(Keys.ARROW_LEFT);
    GridCellElement cell = getGridElement().getCell(2, 1);
    assertTrue(cell.isFocused());

    scrollGridHorizontallyTo(10000);

    //
    getGridElement().getHeaderCell(0, 9).click();
    cell = getGridElement().getHeaderCell(0, 9);
    assertTrue(cell.isFocused());
    toggleHideColumnAPI(10);
    toggleHideColumnAPI(11);

    new Actions(getDriver()).sendKeys(Keys.ARROW_RIGHT);
    new Actions(getDriver()).sendKeys(Keys.ARROW_RIGHT);
    toggleHideColumnAPI(10);
    toggleHideColumnAPI(11);
    cell = getGridElement().getHeaderCell(0, 9);
    assertTrue(cell.isFocused());
}

From source file:GlennsPack.GlennWebAPI.Bot2048.java

License:Open Source License

public Bot2048() {
    System.setProperty("webdriver.chrome.driver", "C:/Users/Glenn/Downloads/chromedriver/chromedriver.exe");
    WebDriver driver = new ChromeDriver();

    driver.manage().window().setSize(new Dimension(2000, 800));

    driver.get("http://annimon.github.io/16384/");

    //      try {
    //         Thread.sleep(2000);
    //      } catch (Exception e) {
    //         // FIXME: handle exception
    //      }/*from   w ww . ja v  a 2 s  . c  om*/
    //      
    WebElement element = driver.findElement(By.xpath("/html/body/div"));
    //            ("/html/body/div/div[2]"));

    Actions actions = new Actions(driver);
    actions.moveToElement(element);
    actions.click();
    CharSequence[] array = { Keys.ARROW_DOWN, Keys.ARROW_LEFT, Keys.ARROW_RIGHT };
    for (int i = 0; i < 1000000; i++) {
        Random random = new Random();
        actions.sendKeys(array[random.nextInt(3)]);
        ;
        actions.sendKeys(Keys.ARROW_DOWN);
        actions.build().perform();
        try {
            //         Thread.sleep(1);
        } catch (Exception e) {
            // FIXME: handle exception
        }
    }
}

From source file:org.alfresco.po.share.site.document.FilmstripActions.java

License:Open Source License

/**
 * Filmstrip view send left arrow.//from ww w .  ja v  a2  s  .c  o  m
 */
public HtmlPage sendKeyLeftArrowForFilmstrip() {
    return sendKeysFilmStripViewElement("Send left key ", Keys.TAB, Keys.ARROW_LEFT);
}