@JavascriptEnabled @Ignore( value = {HTMLUNIT, IPHONE, SELENESE, ANDROID}, reason = "untested user agents") @Test public void testShouldReportKeyCodeOfArrowKeysUpDownEvents() { assumeFalse( Browser.detect() == Browser.opera && TestUtilities.getEffectivePlatform().is(Platform.WINDOWS)); driver.get(pages.javascriptPage); WebElement result = driver.findElement(By.id("result")); 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("")); }
@JavascriptEnabled @Ignore( value = {HTMLUNIT, IE, IPHONE, SELENESE, ANDROID}, reason = "firefox-specific. Android uses prev/next.") @Test public void testShouldReportKeyCodeOfArrowKeys() { assumeFalse( Browser.detect() == Browser.opera && TestUtilities.getEffectivePlatform().is(Platform.WINDOWS)); driver.get(pages.javascriptPage); WebElement result = driver.findElement(By.id("result")); 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("")); }