List of usage examples for org.openqa.selenium Keys BACK_SPACE
Keys BACK_SPACE
To view the source code for org.openqa.selenium Keys BACK_SPACE.
Click Source Link
From source file:org.xwiki.test.ui.XWikiWebDriver.java
License:Open Source License
/** * Compared to using clear() + sendKeys(), this method ensures that an "input" event is triggered on the JavaScript * side for an empty ("") value. Without this, the clear() method triggers just a "change" event. * * @param textInputElement an element accepting text input * @param newTextValue the new text value to set * @see <a href="https://code.google.com/p/selenium/issues/detail?id=214">Issue 214</a> * @since 7.2M3//from w ww .j av a2s.c om */ public void setTextInputValue(WebElement textInputElement, String newTextValue) { if (StringUtils.isEmpty(newTextValue)) { // Workaround for the fact that clear() fires the "change" event but not the "input" event and javascript // listening to the "input" event will not be executed otherwise. // Note 1: We're not using CTRL+A and the Delete because the key combination to select the full input // depends on the OS (on Mac it's META+A for example). // Note 2: Sending the END key didn't always work when I tested it on Mac (for some unknown reason) textInputElement.click(); textInputElement.sendKeys(StringUtils.repeat(Keys.ARROW_RIGHT.toString(), textInputElement.getAttribute("value").length())); textInputElement.sendKeys(StringUtils.repeat(Keys.BACK_SPACE.toString(), textInputElement.getAttribute("value").length())); } else { textInputElement.clear(); textInputElement.sendKeys(newTextValue); } }
From source file:org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase.java
License:Open Source License
public void typeBackspace(int count, boolean hold) { sendKey(Keys.BACK_SPACE, count, hold); }
From source file:org.zanata.page.projects.ProjectVersionsPage.java
License:Open Source License
public ProjectVersionsPage clearVersionSearch() { log.info("Clear version search field"); int maxKeys = 500; while (!readyElement(versionSearchInput).getAttribute("value").isEmpty() && maxKeys > 0) { readyElement(versionSearchInput).sendKeys(Keys.BACK_SPACE); maxKeys = maxKeys - 1;// w w w . j a v a 2 s. c o m } if (maxKeys == 0) { log.warn("Exceeded max keypresses for clearing search bar"); } return new ProjectVersionsPage(getDriver()); }
From source file:projectGutenbergTest.GutenbergTest.java
@Test public void Test2() { WebElement element = driver.findElement(By.id("titleAuthorWithCityTextBox")); element.sendKeys("Esbjerg"); WebElement element2 = driver.findElement(By.name("ctl02")); element2.click();//from w w w . j av a 2 s .co m (new WebDriverWait(driver, maxTimer)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { int amount = d.findElements(By.xpath("//tbody/tr")).size(); return amount == 6; } }); //Get from file later expectedBooks = new ArrayList<ExpectedOutput>(); expectedBooks.add(new ExpectedOutput("Denmark", "M. Pearson Thomson,")); expectedBooks.add(new ExpectedOutput("The 1990 CIA World Factbook", "M. United States. Central Intelligence Agency,")); expectedBooks.add( new ExpectedOutput("The 1994 CIA World Factbook", "United States Central Intelligence Agency,")); expectedBooks.add( new ExpectedOutput("The 1997 CIA World Factbook", "United States. Central Intelligence Agency.,")); expectedBooks.add( new ExpectedOutput("The 1998 CIA World Factbook", "United States. Central Intelligence Agency.,")); expectedBooks.get(0).title.equals(Compare(driver, 2).title); expectedBooks.get(1).title.equals(Compare(driver, 3).title); expectedBooks.get(2).title.equals(Compare(driver, 4).title); expectedBooks.get(3).title.equals(Compare(driver, 5).title); expectedBooks.get(4).title.equals(Compare(driver, 6).title); for (int i = 1; i < 8; i++) { driver.findElement(By.id("titleAuthorWithCityTextBox")).sendKeys(Keys.BACK_SPACE); } }
From source file:projectGutenbergTest.GutenbergTest.java
@Test public void Test4() { WebElement element = driver.findElement(By.id("mentionedInBookTextbox")); element.sendKeys("Jingle Bells"); WebElement element2 = driver.findElement(By.name("ctl04")); element2.click();/*ww w . jav a 2s. co m*/ for (int i = 1; i < 8; i++) { driver.findElement(By.id("mentionedInBookTextbox")).sendKeys(Keys.BACK_SPACE); } }
From source file:projectGutenbergTest.GutenbergTest.java
@Test public void Test6() { WebElement element = driver.findElement(By.id("citiesWithAuthorTextBox")); element.sendKeys("Helen Bannerman"); WebElement element2 = driver.findElement(By.name("ctl06")); element2.click();// w w w .j a v a 2s . c o m for (int i = 1; i < 8; i++) { driver.findElement(By.id("mentionedInBookTextbox")).sendKeys(Keys.BACK_SPACE); } }
From source file:SeleniumTest.selenium.SeleniumTest.java
@Test public void cTestResultFilter() { driver.navigate().to("http://localhost:3000/"); WebElement searchFilter = driver.findElement(By.id("filter")); searchFilter.sendKeys("2002"); int rowCount = driver.findElements(By.xpath("//table[@class='table']/tbody/tr")).size(); assertEquals(2, rowCount);//from w w w. ja va 2 s .co m searchFilter.sendKeys(Keys.BACK_SPACE); int rows = driver.findElements(By.xpath("//table[@class='table']/tbody/tr")).size(); assertEquals(5, rows); }
From source file:uk.gov.gchq.gaffer.ui.QueryBuilderST.java
License:Apache License
private void backspace(final String id) { WebElement bs = getElement(id); bs.click(); bs.sendKeys(Keys.BACK_SPACE); }