Example usage for org.openqa.selenium WebElement sendKeys

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

Introduction

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

Prototype

void sendKeys(CharSequence... keysToSend);

Source Link

Document

Use this method to simulate typing into an element, which may set its value.

Usage

From source file:com.continuuity.test.pagetest.CreateProviderTest.java

License:Apache License

@Test
public void test_03_submitProviderError() throws Exception {
    globalDriver.get(Constants.PROVIDER_CREATE_URI);
    assertFalse(globalDriver.findElement(By.cssSelector("#notification")).isDisplayed());
    WebElement inputName = globalDriver.findElement(By.cssSelector("#providerName"));
    inputName.sendKeys("asdf");
    WebElement inputDescription = globalDriver.findElement(By.cssSelector("#inputDescription"));
    inputDescription.sendKeys("asdf");
    // Submit form without provisioner field.
    globalDriver.findElement(By.cssSelector("#create-provider-form")).submit();
    assertTrue(globalDriver.findElement(By.cssSelector("#notification")).isDisplayed());
    String errText = globalDriver.findElement(By.cssSelector("#notification")).getText();
    assertEquals("Provider type empty.", errText);

    // Submit form after selecting provisioner field.
    WebElement inputProvisioner = globalDriver.findElement(By.cssSelector("#provisioner-select"));
    inputProvisioner.sendKeys("joyent");
    globalDriver.findElement(By.cssSelector("#create-provider-form")).submit();
    errText = globalDriver.findElement(By.cssSelector("#notification")).getText();
    assertEquals("Route handler not available.", errText);
}

From source file:com.continuuity.test.pagetest.CreateServiceTest.java

License:Apache License

@Test
public void test_01_submitHadoopHdfsDatanode() throws Exception {
    globalDriver.get(Constants.SERVICE_CREATE_URI);
    Service service = EXAMPLE_READER.getServices(Constants.SERVICES_PATH).get("hadoop-hdfs-datanode");
    WebElement inputName = globalDriver.findElement(By.name("inputName"));
    inputName.sendKeys(service.getName());
    WebElement inputDescription = globalDriver.findElement(By.cssSelector("#inputDescription"));
    inputDescription.sendKeys(service.getDescription());

    Select dependsOn = new Select(globalDriver.findElement(By.cssSelector("#inputRuntimeRequires")));
    WebElement addService = globalDriver.findElement(By.cssSelector("#add-service"));
    dependsOn.selectByVisibleText("base");
    addService.click();/*from   w  w  w .  j  a v a2s  . c  om*/

    dependsOn.selectByVisibleText("hadoop-hdfs-namenode");
    addService.click();

    WebElement addAction = globalDriver.findElement(By.cssSelector("#add-action"));
    addAction.click();
    addAction.click();
    addAction.click();
    addAction.click();

    List<WebElement> actionEntries = globalDriver.findElements(By.cssSelector(".action-entry"));

    actionEntries.get(0).findElement(By.cssSelector(".inputCategory")).sendKeys("install");
    actionEntries.get(0).findElement(By.cssSelector(".inputType")).sendKeys("chef-solo");
    actionEntries.get(0).findElement(By.name("run_list")).sendKeys(
            service.getProvisionerActions().get(ProvisionerAction.INSTALL).getFields().get("run_list"));
    String data = service.getProvisionerActions().get(ProvisionerAction.INSTALL).getFields()
            .get("json_attributes");
    if (data != null) {
        actionEntries.get(0).findElement(By.name("json_attributes")).sendKeys(data);
    }

    actionEntries.get(1).findElement(By.cssSelector(".inputCategory")).sendKeys("configure");
    actionEntries.get(1).findElement(By.cssSelector(".inputType")).sendKeys("chef-solo");
    actionEntries.get(1).findElement(By.name("run_list")).sendKeys(
            service.getProvisionerActions().get(ProvisionerAction.CONFIGURE).getFields().get("run_list"));
    data = service.getProvisionerActions().get(ProvisionerAction.CONFIGURE).getFields().get("json_attributes");
    if (data != null) {
        actionEntries.get(1).findElement(By.name("json_attributes")).sendKeys(data);
    }

    actionEntries.get(2).findElement(By.cssSelector(".inputCategory")).sendKeys("start");
    actionEntries.get(2).findElement(By.cssSelector(".inputType")).sendKeys("chef-solo");
    actionEntries.get(2).findElement(By.name("run_list"))
            .sendKeys(service.getProvisionerActions().get(ProvisionerAction.START).getFields().get("run_list"));
    data = service.getProvisionerActions().get(ProvisionerAction.START).getFields().get("json_attributes");
    if (data != null) {
        actionEntries.get(2).findElement(By.name("json_attributes")).sendKeys(data);
    }

    actionEntries.get(3).findElement(By.cssSelector(".inputCategory")).sendKeys("stop");
    actionEntries.get(3).findElement(By.cssSelector(".inputType")).sendKeys("chef-solo");
    actionEntries.get(3).findElement(By.name("run_list"))
            .sendKeys(service.getProvisionerActions().get(ProvisionerAction.STOP).getFields().get("run_list"));
    data = service.getProvisionerActions().get(ProvisionerAction.STOP).getFields().get("json_attributes");
    if (data != null) {
        actionEntries.get(3).findElement(By.name("json_attributes")).sendKeys(data);
    }

    globalDriver.findElement(By.cssSelector("#create-service-form")).submit();
    Global.driverWait(1);
    assertEquals(Constants.SERVICES_URL, globalDriver.getCurrentUrl());
}

From source file:com.continuuity.test.pagetest.CreateServiceTest.java

License:Apache License

@Test
public void test_02_submitServiceError() throws Exception {
    globalDriver.get(Constants.SERVICE_CREATE_URI);
    assertFalse(globalDriver.findElement(By.cssSelector("#notification")).isDisplayed());
    WebElement inputName = globalDriver.findElement(By.name("inputName"));
    inputName.sendKeys("asdf");
    WebElement inputDescription = globalDriver.findElement(By.cssSelector("#inputDescription"));
    inputDescription.sendKeys("asdf");
    globalDriver.findElement(By.cssSelector("#create-service-form")).submit();
    assertTrue(globalDriver.findElement(By.cssSelector("#notification")).isDisplayed());
}

From source file:com.daarons.transfer.DownloadTask.java

License:Apache License

private void enterPassword(String password) {
    WebElement passwordInput = driver.findElement(
            By.cssSelector("body > div > div > div.transfer > div > div.transfer__contents > div > input"));
    passwordInput.sendKeys(password);
    WebElement enterPasswordBtn = driver.findElement(By.className("transfer__button"));
    enterPasswordBtn.click();//w  w w  . j ava  2s.  c  om
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private boolean logIn(String emailAddress, String password) {
    try {//w w w  .j a v  a  2  s  . c  o  m
        WebElement emailInput = longWait.until(ExpectedConditions.presenceOfElementLocated(
                By.cssSelector("#signin__form > div > div > form > div:nth-child(1) > input")));
        emailInput.sendKeys(emailAddress);
        WebElement passwordInput = longWait.until(ExpectedConditions.presenceOfElementLocated(
                By.cssSelector("#signin__form > div > div > form > div:nth-child(2) > input")));
        passwordInput.sendKeys(password);
        WebElement logInButton = longWait.until(ExpectedConditions
                .presenceOfElementLocated(By.cssSelector("#signin__form > div > div > form > button")));
        logInButton.click();
        Thread.sleep(5000);
        return true;
    } catch (Exception ex) {
        log.error("Problem", ex);
        return false;
    }
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private void inputMessage(Message message) {
    WebElement toInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__fields > div.uploader__autosuggest > input")));
    toInput.clear();//ww  w  . j a  v a 2s.c om
    toInput.sendKeys(message.getTo());
    WebElement fromInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__fields > input")));
    fromInput.clear();
    fromInput.sendKeys(message.getFrom());
    WebElement messageInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__fields > div.uploader__message > textarea")));
    messageInput.clear();
    messageInput.sendKeys(message.getMessage());
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private void enterUploadPassword(String transferPassword) {
    WebElement transferPasswordInput = longWait
            .until(ExpectedConditions.presenceOfElementLocated(By.id("transfer__password")));
    transferPasswordInput.sendKeys(transferPassword);
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private void inputFilePath(String filePath) {
    WebElement fileInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__files > form > input[type=\"file\"]")));
    fileInput.sendKeys(filePath);
}

From source file:com.davidgaskins.learningtounittest.Utilities.java

License:Apache License

public static void inputString(WebDriver driver, String pathToElement, String input) {
    WebElement element = getElement(driver, pathToElement);
    element.sendKeys(input);
    tryToWait(timeToWait);// w ww  . j a v a2 s  .  co  m
}

From source file:com.day.cq.social.comments.CloudServiceMTIT.java

@Test
public void testConfigureMSConnectorOnPublish() throws InterruptedException {
    browseTo(getURL(cloudServiceMTPage), true);
    WebElement msConnector = driver.findElement(By.cssSelector("div.product.msft-translation a"));
    msConnector.click();//from   w w  w .  j ava2s  .com
    assertTrue("Unable to find configuration button",
            isElementPresent(By.cssSelector("#msft-translation-more")));
    assertTrue("Unable to find default configuration", isElementPresent(
            By.linkText("Microsoft Translator Default Configuration (Microsoft Translation Configuration)")));
    assertTrue("Unable to find trail configuration", isElementPresent(
            By.linkText("Microsoft Translator Trial License (Microsoft Translation Configuration)")));

    WebElement defaultConfig = driver.findElement(
            By.linkText("Microsoft Translator Default Configuration (Microsoft Translation Configuration)"));
    defaultConfig.click();
    WebElement edit = driver.findElement(By.id("cq-gen14"));
    edit.click();

    WebElement label = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1021 input"));
    WebElement attribution = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1022 input"));
    WebElement workspaceID = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1023 input"));
    WebElement clientID = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1024 input"));
    WebElement clientSecret = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1025 input"));
    label.clear();
    label.sendKeys("test");
    attribution.clear();
    attribution.sendKeys("test");
    workspaceID.clear();
    workspaceID.sendKeys("test");
    clientID.clear();
    clientID.sendKeys("AdobeAEMTrial");
    clientSecret.clear();
    clientSecret.sendKeys("AEMTrialAccount9468uTp");
    WebElement verifyButton = driver.findElement(By.id("cq-gen65"));
    verifyButton.click();
    WebElement okButton = driver.findElement(By.id("cq-gen90"));
    okButton.click();
    okButton = driver.findElement(By.id("cq-gen44"));
    okButton.click();

    Thread.sleep(2000);
    List<WebElement> property = driver.findElements(By.cssSelector("#cq-gen8 li"));
    Iterator it = property.iterator();
    it.next();

    assertEquals("Translation Label: test", ((WebElement) it.next()).getText());

}