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.mkl.websuites.internal.command.impl.key.TypeTextCommand.java

License:Apache License

@Override
protected void doOperationOnElement(WebElement elem) {
    String text = populateStringWithProperties(textToType);
    elem.sendKeys(text);

}

From source file:com.moodle.testmanager.FormActions.java

License:GNU General Public License

/**
 * Enters a value in either of the two default text entry area plugins.
 * @param textEntryAreaID The ID of the text entry area.
 * @param message The message to enter in the field.
 * @throws Exception Throws a descriptive exception if the plugins are not available as this would imply that
 * <br/> a) The text area editor is broken.
 * <br/> b) Someone has changed something that has broken the test.
 * <br/> c) A third party plugin is implemented as the default text editor.
 *///from w  w w.  j  a  v  a  2  s.c om
public void enterValueInTextArea(CharSequence message) throws Exception {
    driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
    boolean itemVisible = false;
    boolean mceVisible = false;
    try {
        WebElement e = driver.findElementByTagName(TEXTAREA);
        itemVisible = e.isDisplayed();
        WebElement emce = driver.findElement(By.tagName(IFRAME));
        mceVisible = emce.isDisplayed();
    } catch (Exception e) {
    }
    if (itemVisible) {
        WebElement e = driver.findElementByTagName(TEXTAREA);
        e.sendKeys(message);
    } else if (mceVisible) {
        WebElement messagebox = driver.findElementByTagName(IFRAME);
        driver.switchTo().frame(messagebox);
        WebElement richTextBox = driver.findElement(By.id(TINYMCE));
        richTextBox.click();
        richTextBox.sendKeys(message);
        driver.switchTo().window(driver.getWindowHandle());
    } else {
        throw new Exception(exceptionNoTextEditor);
    }
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

From source file:com.moodle.testmanager.FormActions.java

License:GNU General Public License

public void enterValueGenericTinyMCE(CharSequence message, String tableID) {
    WebElement messagebox = driver.findElement(By.xpath(locGenXpathPrefix + tableID + locGenXpathSuffix));
    driver.switchTo().frame(messagebox);
    WebElement richTextBox = driver.findElement(By.id(TINYMCE));
    richTextBox.click();/*from w w w . j ava  2  s.c  o m*/
    richTextBox.sendKeys(message);
    driver.switchTo().window(driver.getWindowHandle());

}

From source file:com.moodle.testmanager.pageObjectModel.AssignmentAddAssignmentForm.java

License:GNU General Public License

/**
 * Enters a string the is passed from the test in the ID number field.
 * @param ID The value for ID number, can be anything that will pass validation.
 *//*from  w w w.  jav a2 s  .  c  o  m*/
public void enterID(String ID) {
    WebElement text = this.driver.findElementById("id_cmidnumber");
    text.sendKeys(ID);
}

From source file:com.moodle.testmanager.pageObjectModel.AssignmentAddSubmission.java

License:GNU General Public License

/**
 * Enters a value for folder name./* ww w  .jav a2 s.  c  om*/
 * @param folderName The desired name of the folder. Pass from the test.
 */
public void enterTextFolderName(String folderName) {
    WebElement yuiTextField = driver.findElementByCssSelector("input[type='text']");
    yuiTextField.sendKeys(folderName);
}

From source file:com.moodle.testmanager.pageObjectModel.AssignmentGrading.java

License:GNU General Public License

/**
 * Enters a value for desired grade if the grade is a standard grade i.e. not a rubric.
 * @param desiredGrade The grade that you want to enter. Pass this from the test.
 *//*w w  w  . j av  a2  s  . c  o m*/
public void enterTextStandardGrade(String desiredGrade) {
    WebElement text = driver.findElementById("id_grade");
    text.sendKeys(desiredGrade);
}

From source file:com.moodle.testmanager.pageObjectModel.AssignmentSubmissionComments.java

License:GNU General Public License

/**
 * Enters text in the submission comments text box.
 * @param desiredComment The text that you want to enter in the comments box. Pass from the test.
 *//*from   w w w.j  a va  2 s .  c  o  m*/
public void enterTextSubmissionComments(String desiredComment) {
    @SuppressWarnings("unused")
    WebElement myDynamicElement = (new WebDriverWait(driver, 10)).until(new ExpectedCondition<WebElement>() {
        @Override
        public WebElement apply(WebDriver d) {
            return d.findElement(By.xpath("//div[@class='comment-area']/div/textarea"));
        }
    });
    WebElement textArea = driver.findElement(By.xpath("//div[@class='comment-area']/div/textarea"));
    textArea.sendKeys(desiredComment);
}

From source file:com.moodle.testmanager.pageObjectModel.Databases.java

License:GNU General Public License

/**
 * Enter Data in advanced search text field
 * @param fieldName the literal text associated with the field label.
 * @param inputValue The value to be entered as search criteria.
 *//*from w w  w. j  av a 2s  .com*/
public void enterDataAdvancedSearchTextField(String fieldName, String inputValue) {
    WebElement advancedText = driver.findElement(By.xpath(".//tr[contains(.,'" + fieldName + "')]/*/input"));
    advancedText.sendKeys(inputValue);
}

From source file:com.moodle.testmanager.pageObjectModel.DatabasesFields.java

License:GNU General Public License

/**
 * Enters a value in the Field name field.
 * @param fieldName The value you would like to enter.
 *///from   w  w  w.  j  av  a2 s.  com
public void enterFieldName(String fieldName) {
    WebElement field = driver.findElement(By.id("name"));
    field.sendKeys(fieldName);
}

From source file:com.moodle.testmanager.pageObjectModel.DatabasesFields.java

License:GNU General Public License

/**
 * Enters a value in the Field description field. 
 * @param fieldDescription The value you would like to enter.
 *//*from  www . ja  va 2  s  .  c  om*/
public void enterFieldDescription(String fieldDescription) {
    WebElement field = driver.findElement(By.id("description"));
    field.sendKeys(fieldDescription);
}