List of usage examples for org.openqa.selenium WebElement sendKeys
void sendKeys(CharSequence... keysToSend);
From source file:com.googlesites.LoginPage.java
public void typeEmail(String email) { WebElement emailEl = driver.findElement(By.id("Email")); driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); if (emailEl.getAttribute("value") != null) { emailEl.clear();//from ww w . j ava2s . c o m } emailEl.sendKeys(email); driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); String actualSetEmail = emailEl.getAttribute("value"); if (!actualSetEmail.equals(email)) { typeEmail(email); } }
From source file:com.googlesites.LoginPage.java
public void typePassword(String password) { WebElement pass = driver.findElement(By.id("Passwd")); driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); if (pass.getAttribute("value") != null) { pass.clear();/*from w w w . j av a2 s. com*/ } pass.sendKeys(password); driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); String actualSetPassword = pass.getAttribute("value"); if (!actualSetPassword.equals(password)) { typePassword(password); } }
From source file:com.hack23.cia.systemintegrationtest.UserPageVisit.java
License:Apache License
/** * Logout user./*w w w . j a v a 2s . com*/ * * @throws Exception * the exception */ public void logoutUser() throws Exception { final WebElement logoutButton = findButton("Logout"); assertNotNull("Expect to find a Logout Button", logoutButton); final Cookie cookie = driver.manage().getCookieNamed("JSESSIONID"); final String sessionId = cookie.getValue(); performClickAction(logoutButton); final WebElement body = driver.findElement(By.tagName("body")); body.sendKeys(Keys.ESCAPE); waitForBrowser(1000); driver.navigate().refresh(); waitForBrowser(2000); final Cookie newCookie = driver.manage().getCookieNamed("JSESSIONID"); final String newSessionId = newCookie.getValue(); assertNotEquals(sessionId, newSessionId); final String url = systemTestTargetUrl + "#!" + CommonsViews.MAIN_VIEW_NAME; assertEquals(browser, url, driver.getCurrentUrl()); }
From source file:com.hack23.cia.systemintegrationtest.UserPageVisit.java
License:Apache License
/** * Sets the field value.//from w w w . j av a 2s . c om * * @param id * the id * @param value * the value */ private void setFieldValue(final String id, final String value) { final WebElement findElement = driver.findElement(By.id(id)); findElement.clear(); findElement.sendKeys(value); }
From source file:com.hotwire.selenium.bex.BexAbstractPage.java
License:Open Source License
protected void setText(By byElement, String inputText) { WebElement element = getWebDriver().findElement(byElement); element.clear();// www . j a va 2s . co m element.sendKeys(inputText); }
From source file:com.hotwire.selenium.bex.BexAbstractPage.java
License:Open Source License
protected void setText(String cssSelector, String inputText, int timeInSeconds) { WebElement element = findOne(cssSelector, timeInSeconds); element.clear();/*from w w w. java2 s . c om*/ element.sendKeys(inputText); }
From source file:com.hotwire.selenium.bex.BexAbstractPage.java
License:Open Source License
protected void setTextAndSubmit(String cssSelector, String inputText) { WebElement element = getWebDriver().findElement(By.cssSelector(cssSelector)); element.clear();//from ww w .j ava 2 s . c om element.sendKeys(inputText); element.sendKeys(Keys.ENTER); }
From source file:com.hotwire.selenium.desktop.refreshUtil.RefreshUtilPage.java
License:Open Source License
public void setupProperty(String propName, String propValue) { WebElement propertyBox = getWebDriver() .findElement(By.xpath("//table//tr//td//input[contains(@name, 'propValue" + propName + "')]//..")); WebElement input = propertyBox .findElement(By.xpath("//input[contains(@name, 'propValue" + propName + "')]")); input.clear();// w w w. j a v a 2 s .c om input.sendKeys(propValue); propertyBox.findElement(By.xpath("//input[contains(@onclick, 'propValue" + propName + "')]")).click(); }
From source file:com.hotwire.selenium.desktop.row.search.AbstractFareFinder.java
License:Open Source License
@Override public FareFinder setDestinationLocation(String destinationLocation) { location.setText(destinationLocation); try {/* ww w . ja va 2 s.c o m*/ WebElement autocomplete = new WebDriverWait(getWebDriver(), 5) .until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//input[@id='location']/..//div[@class='yui-ac-content']"))); autocomplete.sendKeys(Keys.ESCAPE); } catch (TimeoutException e) { logger.info("Autocomplete failed to become visible... Continuing..."); } return this; }
From source file:com.hotwire.selenium.desktop.subscription.SubscriptionModuleFragment.java
License:Open Source License
public void typeEmail(String email) { WebElement emailElement = getWebDriver() .findElement(By.cssSelector(SUBSCRIPTION_MODULE + " input[name='email']")); emailElement.clear();/* w ww . ja va2 s . c o m*/ emailElement.sendKeys(email); }