Example usage for org.openqa.selenium WebElement clear

List of usage examples for org.openqa.selenium WebElement clear

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement clear.

Prototype

void clear();

Source Link

Document

If this element is a form entry element, this will reset its value.

Usage

From source file:org.apache.falcon.regression.ui.search.ProcessWizardPage.java

License:Apache License

public void setAcl(ACL acl) {
    final WebElement aclOwner = getAclOwner();
    aclOwner.clear();
    aclOwner.sendKeys(acl.getOwner());//from  ww  w.  ja va 2  s. c  o  m
    final WebElement aclGroup = getAclGroup();
    aclGroup.clear();
    aclGroup.sendKeys(acl.getGroup());
    final WebElement aclPerm = getAclPerm();
    aclPerm.clear();
    aclPerm.sendKeys(acl.getPermission());
}

From source file:org.apache.openmeetings.test.selenium.SeleniumUtils.java

License:Apache License

public static void inputText(WebDriver driver, String search, String inputText) throws Exception {
    WebElement element = SeleniumUtils.findElement(driver, search, true, true);

    //clear text before adding input
    element.clear();

    // Would make send to check if this element is really an input text
    element.sendKeys(inputText);/*  www .j a v  a  2  s. c  o  m*/
}

From source file:org.apache.portals.pluto.test.utilities.SimpleTestDriver.java

License:Apache License

/**
 * Called to login to the portal if necessary.
 */// w  w w .  ja v a  2 s .c  om
protected static void login() {

    driver.get(loginUrl);

    List<WebElement> uels = driver.findElements(By.id(usernameId));
    List<WebElement> pwels = driver.findElements(By.id(passwordId));

    // If there is no login or password fields, don't need to login.
    if (!uels.isEmpty() && !pwels.isEmpty()) {

        System.out.println("login: found userid and password fields");
        WebElement userEl = uels.get(0);
        WebElement pwEl = pwels.get(0);

        // perform login
        userEl.clear();
        userEl.sendKeys(username);
        pwEl.clear();
        pwEl.sendKeys(password);
        pwEl.submit();

    }
}

From source file:org.apache.rave.integrationtests.steps.CategoryAdminSteps.java

License:Apache License

@When("I change the name of the category to \"$categoryName\"")
public void fillInUpdatedCategory(String categoryName) {
    WebElement form = portal.findElement(By.id("updateCategory"));
    WebElement field = form.findElement(By.id("text"));
    field.clear();
    field.sendKeys(categoryName);// ww  w .  j a v a 2 s  .co m
}

From source file:org.apache.rave.integrationtests.steps.PageOperationsSteps.java

License:Apache License

private void changeFieldValue(String fieldId, String value) {
    final WebElement field = portal.findElement(By.id(fieldId));
    field.clear();
    field.sendKeys(value);/*from w ww . j a v  a 2  s. co  m*/
}

From source file:org.apache.roller.selenium.AbstractRollerPage.java

License:Apache License

protected void setFieldValue(String fieldId, String value) {
    WebElement field = driver.findElement(By.id(fieldId));
    field.clear();
    field.sendKeys(value);//  w ww .j  av  a 2s  . c om
}

From source file:org.arquillian.droidium.showcase.recorder.test01.DroidiumRecordingTestCase.java

License:Apache License

@Test
@InSequence(2)/*  w  w w. j a  va 2s.  co m*/
public void test02() throws Exception {

    // check value in name field, clear it and write new one
    WebElement inputName = driver.findElement(By.id("inputName"));
    Assert.assertEquals(inputName.getText(), USER_REAL_OLD);
    inputName.clear();
    inputName.sendKeys(USER_REAL_NAME);
    Assert.assertEquals(inputName.getText(), USER_REAL_NAME);

    //
    // stops 1st recording of video on Android
    //
    device.stopRecording(VIDEO_1);

    //
    // starts 2nd recording of video on Android
    //
    device.startRecording(new ScreenrecordOptions.Builder().build());

    // enter favorite language
    driver.findElement(By.id("input_preferedProgrammingLanguage")).click();
    driver.findElement(By.linkText(USER_PRGRAMMING_LANGUAGE)).click();

    // accept adds checkbox
    WebElement acceptAddsCheckbox = driver.findElement(By.id("input_adds"));
    Assert.assertEquals(acceptAddsCheckbox.isSelected(), false);

    acceptAddsCheckbox.click();

    // register
    driver.findElement(By.id("btnRegisterUser")).click();

    //
    // stops 2nd recording of video on Android
    //
    device.stopRecording(VIDEO_2);

    Assert.assertTrue(VIDEO_1.exists());
    Assert.assertTrue(VIDEO_2.exists());
}

From source file:org.arquillian.droidium.showcase.recorder.test02.DroidiumRecordingTestCase.java

License:Apache License

@Test
@InSequence(2)/*from  w  w  w. j  a  v a  2  s.c o  m*/
public void test02() throws Exception {

    // check value in name field, clear it and write new one
    WebElement inputName = driver.findElement(By.id("inputName"));
    Assert.assertEquals(inputName.getText(), USER_REAL_OLD);
    inputName.clear();
    inputName.sendKeys(USER_REAL_NAME);
    Assert.assertEquals(inputName.getText(), USER_REAL_NAME);

    // enter favorite language
    driver.findElement(By.id("input_preferedProgrammingLanguage")).click();
    driver.findElement(By.linkText(USER_PRGRAMMING_LANGUAGE)).click();

    // accept adds checkbox
    WebElement acceptAddsCheckbox = driver.findElement(By.id("input_adds"));
    Assert.assertEquals(acceptAddsCheckbox.isSelected(), false);

    acceptAddsCheckbox.click();

    // register
    driver.findElement(By.id("btnRegisterUser")).click();
}

From source file:org.arquillian.droidium.showcase.screenshooter.test01.SelendroidTestAppTestCase.java

License:Apache License

/**
 * Simple test which tries to register some user.
 *
 * @param screenshooter takes screenshots of {@code device}
 * @param device Android device itself, it is not needed in tests as such since we interact only with {@code WebDriver}
 *        injection.//from  w  w w. j a  v  a2s . c  om
 * @param driver {@code WebDriver} injection which sends commands to Selendroid server installed on the Android device.
 */
@Test
@InSequence(1)
public void test01(@ArquillianResource AndroidDevice device) {

    device.getActivityManager().startActivity("io.selendroid.testapp.HomeScreenActivity");

    // where to save taken screenshots, by default to target/screenshots
    screenshooter.setScreenshotTargetDir("target/screenshots-1");

    // take it!
    screenshooter.takeScreenshot();

    // Go to user registration
    driver.findElement(By.id("startUserRegistration")).click();

    // take it as GIF, by default, it is taken as PNG
    screenshooter.setMessage("taking gif").takeScreenshot(ScreenshotType.GIF);

    // enter nick
    WebElement userName = driver.findElement(By.id("inputUserName"));
    userName.sendKeys(USER_NAME);
    Assert.assertEquals(userName.getText(), USER_NAME);

    // enter e-mail
    WebElement inputEmail = driver.findElement(By.id("inputEmail"));
    inputEmail.sendKeys(USER_EMAIL);
    Assert.assertEquals(inputEmail.getText(), USER_EMAIL);

    // enter password
    WebElement inputPassword = driver.findElement(By.id("inputPassword"));
    inputPassword.sendKeys(USER_PASSWORD);
    Assert.assertEquals(inputPassword.getText(), USER_PASSWORD);

    // check value in name field, clear it and write new one
    WebElement inputName = driver.findElement(By.id("inputName"));
    Assert.assertEquals(inputName.getText(), USER_REAL_OLD);
    inputName.clear();
    inputName.sendKeys(USER_REAL_NAME);
    Assert.assertEquals(inputName.getText(), USER_REAL_NAME);

    // enter favorite language
    driver.findElement(By.id("input_preferedProgrammingLanguage")).click();
    driver.findElement(By.linkText(USER_PRGRAMMING_LANGUAGE)).click();

    // accept adds checkbox
    WebElement acceptAddsCheckbox = driver.findElement(By.id("input_adds"));
    Assert.assertEquals(acceptAddsCheckbox.isSelected(), false);

    acceptAddsCheckbox.click();

    screenshooter.setScreenshotTargetDir("target/screenshots-2");

    // from now on, take all images as BMP if not specified otherwise
    screenshooter.setScreenshotType(ScreenshotType.BMP);

    // you can name it, it will be PNG image by default
    screenshooter.takeScreenshot("myscreenshot1");

    // register
    driver.findElement(By.id("btnRegisterUser")).click();

    // or you can specify file format as well
    screenshooter.takeScreenshot("myscreenshot2", ScreenshotType.JPEG);

}

From source file:org.asqatasun.tgol.test.scenario.AbstractWebDriverTestClass.java

License:Open Source License

/**
 *
 * @param elementName/*from w  ww.java 2s  . c  o  m*/
 * @param elementValue
 */
protected void editWebElement(String elementName, String elementValue) {
    WebElement webElement = getWebElementById(elementName);
    webElement.click();
    webElement.clear();
    webElement.sendKeys(elementValue);
}