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:de.dentrassi.pm.testing.UserTest.java

License:Open Source License

private void newRole(final WebElement newRoleInput, final WebElement newRoleButton, final String role) {
    newRoleInput.clear();
    newRoleInput.sendKeys(role);//from w ww.  jav  a2s.  c om
    newRoleButton.click();
}

From source file:demo.seleniumtest.DemoTest.java

@Test
public void test4() {
    //Press the edit button for the car with the id 938. Change the Description to "Cool car", and save changes.
    //Verify that the row for car with id 938 now contains "Cool car" in the Description column

    final String expectedDescription = "Cool car";
    new WebDriverWait(driver, waitTime).until(new Function<WebDriver, Object>() {
        public Boolean apply(WebDriver wd) {
            wd.findElement(By.id("tbodycars"));
            return true;
        }/*from  w  w  w .j  ava  2s.c o m*/
    });

    List<WebElement> rows = driver.findElement(By.id("tbodycars")).findElements(By.tagName("tr"));

    for (WebElement row : rows) {
        List<WebElement> columns = row.findElements(By.tagName("td"));

        if (columns.get(0).getText().equals("938")) {

            columns.get(columns.size() - 1) // Get last td in that tr - which should be: "action"/description
                    .findElements(By.tagName("a")).get(0) // First a tag --> description, not delete
                    .click();

            WebElement descriptionInput = driver.findElement(By.id("description"));
            descriptionInput.clear();
            descriptionInput.sendKeys("Cool car");

            driver.findElement(By.id("save")).click();

            String actualDescription = columns.get(5).getText();

            assertThat(actualDescription, is(expectedDescription));
            break;
        }
    }
}

From source file:dk.dma.ais.abnormal.web.EventsIT.java

License:Open Source License

private void navigateToSearchDialogAndSearchEventsByVessel() {
    navigateToSearchDialog();//w w w .  j  ava  2 s  .com
    WebElement vesselNameCallsignImoField = browser.findElement(id("search-event-vessel"));
    vesselNameCallsignImoField.clear();
    vesselNameCallsignImoField.sendKeys("L");
    WebElement searchByOtherButton = browser.findElement(id("event-search-by-other"));
    searchByOtherButton.click();
    assertNumberOfSearchResults(12);
}

From source file:dk.netarkivet.systemtest.page.DomainConfigurationPageHelper.java

License:Open Source License

public static void setMaxObjects(int value) {
    WebElement maxObjectsField = PageHelper.getWebDriver().findElement(By.name(MAX_OBJECTS_FIELD));
    maxObjectsField.clear();
    maxObjectsField.sendKeys(String.valueOf(value));
}

From source file:dk.netarkivet.systemtest.page.DomainConfigurationPageHelper.java

License:Open Source License

public static void setMaxHops(int value) {
    WebElement maxHopsField = PageHelper.getWebDriver().findElement(By.name(MAX_HOPS));
    maxHopsField.clear();
    maxHopsField.sendKeys(String.valueOf(value));
}

From source file:es.urjc.etsii.code.WebRtcBenchmarkTest.java

License:Apache License

@Before
public void setup() {
    // Set defaults in all browsers
    int sessionsNumber = getProperty(SESSIONS_NUMBER_PROP, SESSIONS_NUMBER_DEFAULT);
    int initSessionNumber = getProperty(INIT_SESSION_NUMBER_PROP, INIT_SESSION_NUMBER_DEFAULT);
    for (int i = 0; i < sessionsNumber; i++) {
        WebDriver[] webDrivers = { getPresenter(i).getBrowser().getWebDriver(),
                getViewer(i).getBrowser().getWebDriver() };

        for (WebDriver webDriver : webDrivers) {
            // Session number
            WebElement sessionNumberWe = webDriver.findElement(By.id("sessionNumber"));
            sessionNumberWe.clear();
            sessionNumberWe.sendKeys(String.valueOf(i + initSessionNumber));

            // Media processing
            String processing = getProperty(MEDIA_PROCESSING_PROP, MEDIA_PROCESSING_DEFAULT);
            Select processingSelect = new Select(webDriver.findElement(By.id("processing")));
            processingSelect.selectByValue(processing);

            // Bandwidth
            String bandwidth = String.valueOf(getProperty(BANDWIDTH_PROP, BANDWIDTH_DEFAULT));
            WebElement bandwidthWe = webDriver.findElement(By.id("bandwidth"));
            bandwidthWe.clear();//from   w ww . j  ava  2s. c o  m
            bandwidthWe.sendKeys(bandwidth);

            // Number of fake clients
            int fakeClientsInt = getProperty(FAKE_CLIENTS_NUMBER_PROP, FAKE_CLIENTS_NUMBER_DEFAULT);
            String fakeClients = String.valueOf(fakeClientsInt);
            WebElement fakeClientsWe = webDriver.findElement(By.id("fakeClients"));
            fakeClientsWe.clear();
            fakeClientsWe.sendKeys(fakeClients);

            // Rate between clients (milliseconds)
            int timeBetweenClients = getProperty(FAKE_CLIENTS_RATE_PROP, FAKE_CLIENTS_RATE_DEFAULT);
            WebElement timeBetweenClientsWe = webDriver.findElement(By.id("timeBetweenClients"));
            timeBetweenClientsWe.clear();
            timeBetweenClientsWe.sendKeys(String.valueOf(timeBetweenClients));

            if (fakeClientsInt > 0) {
                extraTimePerFakeClients = fakeClientsInt * timeBetweenClients / 1000;
            }

            // Remove fake clients
            boolean removeFakeClients = getProperty(FAKE_CLIENTS_REMOVE_PROP, FAKE_CLIENTS_REMOVE_DEFAULT);
            List<WebElement> removeFakeClientsList = webDriver.findElements(By.name("removeFakeClients"));
            removeFakeClientsList.get(removeFakeClients ? 0 : 1).click();

            // Time with all fake clients together (seconds)
            if (removeFakeClients) {
                int playTime = getProperty(FAKE_CLIENTS_TOGETHER_TIME_PROP, FAKE_CLIENTS_TOGETHER_TIME_DEFAULT);
                WebElement playTimeWe = webDriver.findElement(By.id("playTime"));
                playTimeWe.clear();
                playTimeWe.sendKeys(String.valueOf(playTime));

                extraTimePerFakeClients = (extraTimePerFakeClients * 2) + playTime;
            }

            // Number of fake clients per KMS instance
            String fakeClientsPerInstance = String
                    .valueOf(getProperty(FAKE_CLIENTS_PER_KMS_PROP, FAKE_CLIENTS_PER_KMS_DEFAULT));
            WebElement fakeClientsPerInstanceWe = webDriver.findElement(By.id("fakeClientsPerInstance"));
            fakeClientsPerInstanceWe.clear();
            fakeClientsPerInstanceWe.sendKeys(fakeClientsPerInstance);

        }
    }

    if (!outputFolder.endsWith(File.separator)) {
        outputFolder += File.separator;
    }
}

From source file:features.steps.StepUtils.java

License:Apache License

public static void login(String username, String password) {
    navigateTo("/logout.do");
    navigateTo("/");
    WebElement loginLink = driver.findElement(By.id("login"));
    loginLink.click();//from  w w  w  .  j a  v  a  2  s .c  om
    WebElement usernameInput = driver.findElement(By.name("j_username"));
    usernameInput.clear();
    usernameInput.sendKeys(username);
    WebElement passwordInput = driver.findElement(By.name("j_password"));
    passwordInput.clear();
    passwordInput.sendKeys(password);
    WebElement login = driver.findElement(By.name("submit"));

    login.click();
}

From source file:features.steps.StepUtils.java

License:Apache License

public static void associate(String uuid, String description) {
    clickLinkByPartialText("Add Usage Point");

    WebElement uuidElement = driver.findElement(By.name("UUID"));
    uuidElement.clear();
    uuidElement.sendKeys(uuid);//  w  w  w  .  j  a  v a 2 s  .  com

    WebElement descriptionElement = driver.findElement(By.id("description"));
    descriptionElement.sendKeys(description);

    WebElement create = driver.findElement(By.name("create"));
    create.click();
}

From source file:ForgotPassword.TableTracker.java

@Test
public void searchForCreatedLocation() throws Exception {
    System.out.println("IN table tracker");
    login();//ww  w.j a v a2  s.  c o  m

    Thread.sleep(10000);
    System.out.println("Exit Login");
    driver.findElement(By.id("mdSearchBox")).sendKeys("Test");
    //System.out.println(a.LocationName);
    Thread.sleep(10000);
    driver.findElement(By.className("mdMasterTableSecondaryLabel")).click();
    Thread.sleep(3000);
    driver.findElement(By.xpath("//button[@class='btn addProductBtn']")).click();
    Thread.sleep(2000);
    String test = driver.findElement(By.cssSelector("body")).getText();

    if (test.contains(
            "You have reached your license maximum for this Product. Please contact LRS or visit www.lrsus.com for information on purchasing additional licenses.")) {
        System.out.println("***********************************");
        System.out.println("user limit exceed");
        System.out.println("***********************************");
    } else {
        WebElement deviceName = driver.findElement(By.className("input-block-level"));
        deviceName.clear();
        deviceName.sendKeys(incrId + "Test1");
        Thread.sleep(10000);
        driver.findElement(By.className("btn btn-primary saveBtn")).click();
        Thread.sleep(5000);
        System.out.println("Table Tracker module completed");
    }
}

From source file:gov.nasa.jpl.memex.nutch.protocol.selenium.handlers.login.LoginHandler32.java

License:Apache License

public void processDriver(WebDriver driver) {

    String OriginalURL = driver.getCurrentUrl();
    driver.get(OriginalURL);//ww  w .  j  av  a2 s.  c  o  m

    //Find the login button and click on it
    WebElement LoginButton = driver.findElement(By.linkText("Login"));
    LoginButton.click();

    //Find the username textbox using the name of the textbox - which is typically "Username"
    WebElement useremail = driver.findElement(By.linkText("Username"));

    //if username is not found try finding an element with "email"
    if (null == useremail) {
        useremail = driver.findElement(By.linkText("email"));
    }
    useremail.clear();
    useremail.sendKeys("cs572team32@gmail.com");

    WebElement password = driver.findElement(By.linkText("Password"));
    password.clear();
    password.sendKeys("ViewSonic");

    WebElement submitButton = driver.findElement(By.linkText("submit"));
    submitButton.click();
}