List of usage examples for org.openqa.selenium WebElement clear
void clear();
From source file:com.google.appengine.tck.driver.DefaultLoginHandler.java
License:Open Source License
public void login(WebDriver driver, LoginContext context) { WebElement email = driver.findElement(By.id("email")); email.clear(); email.sendKeys(context.getEmail());//from w w w. j av a 2s . com if (context.isAdmin()) { driver.findElement(By.id("isAdmin")).click(); } driver.findElement(By.id("btn-login")).click(); }
From source file:com.google.appengine.tck.env.appspot.AppspotLoginHandler.java
License:Open Source License
public void login(WebDriver driver, LoginContext context) { try {/*from w ww.j av a2 s . com*/ WebElement email = driver.findElement(By.id("Email")); if (email.getAttribute("readonly") == null) { email.clear(); email.sendKeys(context.getEmail()); } WebElement password = driver.findElement(By.id("Passwd")); password.sendKeys(context.getPassword()); driver.findElement(By.name("signIn")).click(); } catch (NoSuchElementException e) { throw new IllegalStateException( String.format("URL[%s]\n\n%s", driver.getCurrentUrl(), driver.getPageSource()), e); } }
From source file:com.google.iphone.testing.nativedriver.client.NativeDriverTest.java
License:Apache License
public void testNativeDriver() throws Exception { WebDriver driver = new IosNativeDriver(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // Type user name WebElement userName = driver.findElement(By.placeholder("User Name")); userName.clear(); userName.sendKeys("NativeDriver"); // Type password WebElement password = driver.findElement(By.placeholder("Password")); password.clear();//from w w w.java2 s.co m password.sendKeys("abcdefgh"); // Tap "Sign in" button driver.findElement(By.text("Sign in")).click(); // Verify correct title is displayed String text = driver.getTitle(); assertEquals("NativeDriver", text); // Type text in WebView WebElement element = driver.findElement(By.name("q")); element.sendKeys("NativeDriver"); element.submit(); // Click link driver.findElement(By.partialLinkText("GUI automation")).click(); // Verify the page assertEquals("nativedriver", driver.findElement(By.id("pname")).getText()); }
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(); }// w w w .jav a 2 s .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(); }// w w w. ja va 2 s. c o m 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
/** * Sets the field value./*from www . j a va 2 s . com*/ * * @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(); element.sendKeys(inputText);//from w w w . j av a 2 s. c o m }
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(); element.sendKeys(inputText);// w ww.j av a 2s . co m }
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(); element.sendKeys(inputText);/* w ww .j a v a2s. c o m*/ 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(); input.sendKeys(propValue);/*from w w w .ja v a 2 s . com*/ propertyBox.findElement(By.xpath("//input[contains(@onclick, 'propValue" + propName + "')]")).click(); }