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:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandler6.java

License:Apache License

public void processDriver(WebDriver driver) {

    //Handler for Login
    System.out.println(driver.getCurrentUrl());

    System.out.println("handler called team 6");

    if (driver.getCurrentUrl().equals("http://www.academy.com/")) {
        System.out.println("team 6- http://www.academy.com");

        driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);

        driver.findElement(By.id("level-six")).click();

        WebElement emailButton = driver.findElement(By.id("WC_AccountDisplay_FormInput_logonId_In_Logon_1"));
        emailButton.clear();
        emailButton.sendKeys("shrutimundra.20@gmail.com");

        WebElement passButton = driver//from   w ww  .jav  a2 s  . c o  m
                .findElement(By.id("WC_AccountDisplay_FormInput_logonPassword_In_Logon_1"));
        passButton.clear();
        passButton.sendKeys("sgpsteam6\n");

    } else if (driver.getCurrentUrl().equals("http://www.arguntrader.com/")) {
        WebElement emailButton = driver.findElement(By.id("username"));

        emailButton.clear();

        emailButton.sendKeys("team6ir4");

        WebElement passButton = driver.findElement(By.id("password"));

        passButton.clear();

        passButton.sendKeys("sgpsteam6\n");

    } else if (driver.getCurrentUrl().equals("http://www.armslist.com/")) {
        WebElement loginButton = driver.findElement(By.linkText("Login"));

        loginButton.click();

        WebElement emailButton = driver.findElement(By.id("email"));

        emailButton.clear();

        emailButton.sendKeys("shrutimundra.20@gmail.com");

        WebElement passButton = driver.findElement(By.id("password"));

        passButton.clear();

        passButton.sendKeys("sgpsteam6\n");

    } else if (driver.getCurrentUrl().equals("http://www.buyusedguns.net/")) {
        WebElement loginButton = driver.findElement(By.linkText("Login"));

        loginButton.click();

        WebElement emailButton = driver.findElement(By.name("username"));

        emailButton.clear();

        emailButton.sendKeys("irteam6");

        WebElement passButton = driver.findElement(By.name("password"));

        passButton.clear();

        passButton.sendKeys("sgpsteam6\n");

    } else if (driver.getCurrentUrl().equals("http://www.cheaperthandirt.com/")) {

        WebElement loginButton = driver.findElement(By.linkText("Sign In"));

        loginButton.click();

        WebElement emailButton = driver.findElement(By.id("ctl00_ContentPlaceHolderTopLevel_txtEmail"));

        emailButton.clear();

        emailButton.sendKeys("team6ir@gmail.com");

        WebElement passButton = driver.findElement(By.id("ctl00_ContentPlaceHolderTopLevel_txtPassword"));

        passButton.clear();

        passButton.sendKeys("sgpsteam6\n");

    } else if (driver.getCurrentUrl().equals("http://www.freeclassifieds.com/")) {

        WebElement loginButton = driver.findElement(By.id("Button1"));

        loginButton.click();

        WebElement emailButton = driver.findElement(By.id("phMain_txtEmail"));

        emailButton.clear();

        emailButton.sendKeys("team6ir@gmail.com");

        WebElement passButton = driver.findElement(By.id("phMain_txtPassword"));

        passButton.clear();

        passButton.sendKeys("sgpsteam6\n");

    } else if (driver.getCurrentUrl().equals("http://freegunclassifieds.com/")) {

        WebElement loginButton = driver.findElement(By.id("login_open"));

        loginButton.click();

        WebElement emailButton = driver.findElement(By.id("email"));

        emailButton.clear();

        emailButton.sendKeys("team6ir@gmail.com");

        WebElement passButton = driver.findElement(By.id("password"));

        passButton.clear();

        passButton.sendKeys("sgpsteam6\n");

    } else if (driver.getCurrentUrl().equals("http://www.gandermountain.com/")) {

        WebElement loginButton = driver.findElement(By.xpath("//*[@class = 'top-level']"));
        loginButton.click();

        WebElement emailButton = driver.findElement(By.id("header-login-email"));

        emailButton.clear();

        emailButton.sendKeys("team6ir@gmail.com");

        WebElement passButton = driver.findElement(By.name("password"));

        passButton.clear();

        passButton.sendKeys("sgpsteam6\n");

    } else if (driver.getCurrentUrl().equals("http://www.gunauction.com/")) {

        //gunauction.com

        WebElement loginButton = driver.findElement(By.className("login-window"));

        loginButton.click();

        WebElement emailButton = driver.findElement(By.name("EMail"));

        emailButton.clear();

        emailButton.sendKeys("team6ir@gmail.com");

        WebElement passButton = driver.findElement(By.name("Password1"));

        passButton.clear();

        passButton.sendKeys("sgpsteam6\n");

    } else if (driver.getCurrentUrl().equals("http://www.gunlistings.org/")) {

        //gunlistings.org

        WebElement loginButton = driver.findElement(By.linkText("Login"));

        loginButton.click();

        WebElement emailButton = driver.findElement(By.name("email_login"));

        emailButton.clear();

        emailButton.sendKeys("team6ir@gmail.com");

        WebElement passButton = driver.findElement(By.name("password"));

        passButton.clear();

        passButton.sendKeys("sgpsteam6\n");

    }
}

From source file:gov.nih.nci.firebird.commons.selenium2.util.FormUtils.java

License:Open Source License

/**
 * Clears an input field and sends the input value as keystrokes
 * to the input.//from   w  w w. j av  a2  s .  co m
 *
 * @param input the input field
 * @param value the value
 */
public static void type(WebElement input, String value) {
    input.clear();
    input.sendKeys(StringUtils.defaultString(value));
}

From source file:gov.nih.nci.firebird.commons.selenium2.util.JQueryUtils.java

License:Open Source License

/**
 * Clears an masked input field and sends the input value as keystrokes to the input.
 *
 * @param maskedInputId ID of the masked input field
 * @param value value to type/*  w w w  . j  a  v a  2  s  .co  m*/
 */
public static void typeInMaskedField(WebDriver driver, String maskedInputId, String value) {
    WebElement maskedInput = driver.findElement(By.id(maskedInputId));
    maskedInput.clear();
    JQueryUtils.triggerBlur(driver, maskedInputId);
    maskedInput.click();
    maskedInput.sendKeys(value);
    JQueryUtils.triggerBlur(driver, maskedInputId);
}

From source file:hu.traininfo.uitest.step.Steps.java

License:Open Source License

@When("I enter $inputValue to field labelled $labelText")
public void enterTextIntoField(String inputValue, String labelText) {
    WebElement inputField = browser.findElement(By.id(HtmlId.getHtmlLabelIdForLabelText(labelText)));
    inputField.clear();
    inputField.sendKeys(inputValue);/*  w ww.  j av  a  2 s  .c  om*/
}

From source file:hu.traininfo.uitest.step.Steps.java

License:Open Source License

@When("I clear field labelled $labelText")
public void clearTextFromField(String labelText) {
    WebElement inputField = browser.findElement(By.id(HtmlId.getHtmlLabelIdForLabelText(labelText)));
    inputField.clear();
}

From source file:ibw.updater.selenium.TestWebIF.java

License:Open Source License

@Test
public void testEditUser() throws InterruptedException {
    assertTrue(createGroup());/*from  www  . ja  va2s.  c  om*/
    driver.navigate().refresh();

    assertTrue(createUser());
    driver.navigate().refresh();

    waitAndClick(By.xpath("//tbody/tr[1]/td[1]//button[starts-with(@data-ng-click, 'showUserDialog')]"));

    waitForElement(By.id("user-dialog"));

    WebElement description = waitForElement(By.id("description"));
    description.clear();
    description.sendKeys(TU_DESCRIPTION_UPDATE);
    waitAndSelectByIndex(By.id("groups"), 0);

    waitAndClick(By.cssSelector(".modal-footer button.btn-primary"));

    Thread.sleep(MAX_WAIT_TIME * 1000);
    driver.navigate().refresh();

    description = waitForElement(By.xpath("//tbody/tr[1]/td[3]"));
    WebElement group = waitForElement(By.xpath("//tbody/tr[1]/td[4]"));

    assertEquals(TU_DESCRIPTION_UPDATE, description.getText());
    assertEquals(TG_NAME, group.getText());

    assertTrue(deleteUser());
    driver.navigate().refresh();

    assertTrue(deleteGroup());
}

From source file:ibw.updater.selenium.TestWebIF.java

License:Open Source License

@Test
public void testEditGroup() throws InterruptedException {
    assertTrue(createUser());//from w  w w . ja  va2  s. c  o  m
    driver.navigate().refresh();

    assertTrue(createGroup());
    driver.navigate().refresh();

    waitAndClick(By.xpath("//tbody/tr[1]/td[1]//button[starts-with(@data-ng-click, 'showGroupDialog')]"));

    waitForElement(By.id("group-dialog"));

    WebElement description = waitForElement(By.id("description"));

    description.clear();
    description.sendKeys(TG_DESCRIPTION_UPDATE);

    waitAndSelectByIndex(By.id("users"), 0);

    waitAndClick(By.cssSelector(".modal-footer button.btn-primary"));

    Thread.sleep(MAX_WAIT_TIME * 1000);

    description = waitForElement(By.xpath("//tbody/tr[1]/td[3]"));
    WebElement user = waitForElement(By.xpath("//tbody/tr[1]/td[4]"));

    assertEquals(TG_DESCRIPTION_UPDATE, description.getText());
    assertEquals(TU_NAME, user.getText());

    assertTrue(deleteGroup());
    driver.navigate().refresh();

    assertTrue(deleteUser());
}

From source file:ibw.updater.selenium.TestWebIF.java

License:Open Source License

@Test
public void testEditCommonPackage() throws InterruptedException {
    createCommonPackage();//  www. j a v  a  2s .  c om
    driver.navigate().refresh();

    waitAndClick(By.xpath("//tbody/tr[1]/td[1]//button[starts-with(@data-ng-click, 'showPackageDialog')]"));

    waitForElement(By.id("package-dialog"));

    WebElement description = waitForElement(By.id("description"));
    description.clear();
    description.sendKeys(TP_DESCRIPTION_UPDATE);

    waitAndClick(By.cssSelector(".modal-footer button.btn-primary"));

    Thread.sleep(MAX_WAIT_TIME * 1000);

    WebElement version = waitForElement(By.xpath("//tbody/tr[1]/td[3]"));
    description = waitForElement(By.xpath("//tbody/tr[1]/td[5]"));

    assertEquals(new Integer(1), new Integer(version.getText()));
    assertEquals(TP_DESCRIPTION_UPDATE, description.getText());

    driver.navigate().refresh();

    waitAndClick(By.xpath("//tbody/tr[1]/td[1]//button[starts-with(@data-ng-click, 'showPackageDialog')]"));

    waitForElement(By.id("package-dialog"));

    WebElement startupScript = waitForElement(By.id("startupScript"));
    startupScript.clear();
    startupScript.sendKeys(TP_SUS_UPDATE);

    waitAndClick(By.cssSelector(".modal-footer button.btn-primary"));

    Thread.sleep(MAX_WAIT_TIME * 1000);

    version = waitForElement(By.xpath("//tbody/tr[1]/td[3]"));
    assertEquals(new Integer(2), new Integer(version.getText()));

    assertTrue(deletePackage());
}

From source file:ibw.updater.selenium.TestWebIF.java

License:Open Source License

@Test
public void testCommonPackageError() throws InterruptedException {
    createCommonPackage();//www.j  a  v  a2  s .co m
    driver.navigate().refresh();

    waitAndClick(By.xpath("//tbody/tr[1]/td[1]//button[starts-with(@data-ng-click, 'showPackageDialog')]"));

    waitForElement(By.id("package-dialog"));

    WebElement startupScript = waitForElement(By.id("startupScript"));
    startupScript.clear();
    startupScript.sendKeys("script/no-found.js");

    waitAndClick(By.cssSelector(".modal-footer button.btn-primary"));

    Thread.sleep(MAX_WAIT_TIME * 1000);

    assertNotNull(waitForElement(By.cssSelector("div.alert.alert-danger")));

    assertTrue(deletePackage());
}

From source file:ibw.updater.selenium.TestWebIF.java

License:Open Source License

@Test
public void testEditUserPackage() throws InterruptedException {
    assertTrue(createUserPackage());/*from ww  w. jav  a  2 s.  com*/
    driver.navigate().refresh();

    waitAndClick(By.xpath("//tbody/tr[1]/td[1]//button[starts-with(@data-ng-click, 'showPackageDialog')]"));

    waitForElement(By.id("package-dialog"));

    WebElement description = waitForElement(By.id("description"));
    description.clear();
    description.sendKeys(TP_DESCRIPTION_UPDATE);

    WebElement function = waitForElement(By.id("function"));
    function.clear();
    function.sendKeys("function HelloAgain() {\nalert(\"Hello Again World!\");\n}");

    waitAndClick(By.cssSelector(".modal-footer button.btn-primary"));

    Thread.sleep(MAX_WAIT_TIME * 1000);

    WebElement version = waitForElement(By.xpath("//tbody/tr[1]/td[3]"));
    description = waitForElement(By.xpath("//tbody/tr[1]/td[5]"));

    assertEquals(new Integer(2), new Integer(version.getText()));
    assertEquals(TP_DESCRIPTION_UPDATE, description.getText());

    assertTrue(deletePackage());
}