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.autocognite.selenium.lib.SeleniumWebUiDriver.java

License:Apache License

public void setText(WebElement wdElement, String text) throws Exception {
    this.waitForElementClickability(wdElement);
    wdElement.click();/*from w w w.j  a  v  a 2s .  c o  m*/
    wdElement.clear();
    wdElement.sendKeys(text);
}

From source file:com.axatrikx.webdriver.AxaDriver.java

License:Apache License

/**
 * Type on the element. If some text is already present on it, it will be
 * cleared before typing. For typing over existing data, use sendKeys
 * method./* w ww  .  j  av  a 2 s  . c o m*/
 * 
 * @param locator
 *            string locator in OR locator format
 * @param keysToType
 *            text to type
 */
public void type(String locator, String keysToType) {
    WebElement ele = eleHelper.findElement(locator);
    ele.clear();
    ele.sendKeys(keysToType);
    reporter.log("Action", "Typed '" + keysToType + "' on element " + locator, ExecutionStatus.INFO);
}

From source file:com.blogspot.jadecalyx.webtools.jcWebPage.java

public void SetText(String objectHandle, String textToSet) {
    Stack<jcPageObjectSet> es = _pageObjectHelper.GetLookupDetails(objectHandle);
    WebElement we = extractElement(null, es);
    we.sendKeys(textToSet);
}

From source file:com.cengage.mindtap.keywords.EvernotePageActions.java

public void AddNote(String note) {
    waitTOSync();//from   w  ww .  j  a  v a  2  s  .c o  m

    element("AddNote").click();
    Assert.assertTrue(element("Note_Title").isDisplayed(), "Title box is not present");
    element("Note_Title").clear();
    element("Note_Title").sendKeys(note);
    waitTOSync();
    switchToDefaultContent();
    switchToDockIFrame();
    switchToFrame("tinymce_editor_area_ifr");

    waitTOSync();
    WebElement element = driver.findElement(By.id("tinymce"));
    System.out.println("Entering note description in text input");
    element.sendKeys(Keys.CONTROL + "a");
    element.sendKeys("Instructor created note description");

    switchToDefaultContent();
    switchToDockIFrame();
    element("SaveNote_Button").click();
    waitTOSync();
    String addedNote_Title = driver.findElement(By.xpath(".//ul[@class='plain']/li[1]/a")).getText();
    System.out.println(addedNote_Title);
    Assert.assertTrue(addedNote_Title.contains(note), "Note is not added");

}

From source file:com.cengage.mindtap.keywords.EvernotePageActions.java

public void editNote() throws AWTException {
    waitTOSync();//w  w w.  ja v  a2s .  c  o m
    waitTOSync();
    element("editNote").click();
    element("Note_Title").clear();
    element("Note_Title").sendKeys("Instructor edited Note");
    switchToDefaultContent();
    switchToDockIFrame();
    switchToFrame("tinymce_editor_area_ifr");

    waitTOSync();
    WebElement element = driver.findElement(By.id("tinymce"));
    driver.findElement(By.id("tinymce")).clear();
    System.out.println("Editing note description in text input");
    //element.sendKeys(Keys.CONTROL + "a");
    element.sendKeys(Keys.CONTROL + "b");

    element.sendKeys("bold edited");

    element.sendKeys(Keys.CONTROL + "b");
    element.sendKeys(Keys.ENTER);
    element.sendKeys(Keys.CONTROL + "i");
    element.sendKeys("Italics edited");

    element.sendKeys(Keys.ENTER);
    element.sendKeys(Keys.CONTROL + "i");
    element.sendKeys("hyperlinked");
    element.sendKeys(Keys.chord(Keys.SHIFT, Keys.HOME));
    waitTOSync();
    switchToDefaultContent();
    switchToDockIFrame();
    element("hyperlink").click();

    windowHandle = driver.getWindowHandle();
    ArrayList<String> tabs2 = new ArrayList<String>(driver.getWindowHandles());
    driver.switchTo().window(tabs2.get(1));
    element("linkBox").clear();
    element("linkBox").sendKeys("http://google.com");
    element("LinkInsert").click();
    waitTOSync();
    driver.switchTo().window(windowHandle);
    System.out.println("window switched");
    switchToDefaultContent();
    switchToDockIFrame();
    switchToFrame("tinymce_editor_area_ifr");
    waitTOSync();
    waitTOSync();
    waitTOSync();
    waitTOSync();
    waitTOSync();
    waitTOSync();
    Assert.assertTrue(element("linkedText").isDisplayed(), "text is not linked");

    switchToDefaultContent();
    switchToDockIFrame();
    element("updateNode_Button").click();
    waitTOSync();
    String addedNote_Title = driver.findElement(By.xpath(".//ul[@class='plain']/li[1]/a")).getText();
    System.out.println(addedNote_Title);
    Assert.assertTrue(addedNote_Title.contains("edited Note"), "edited note is not displayed");

    WebElement bold = driver.findElement(By.xpath("//strong[contains(text(),'bold edited')]"));
    Assert.assertTrue(bold.isDisplayed(), "bold text does not appear");

    WebElement italics = driver.findElement(By.xpath("//em[contains(text(),'Italics edited')]"));
    Assert.assertTrue(italics.isDisplayed(), "italics text does not appear");

    ReportMsg.info("Instructor successfuly edited note");
}

From source file:com.cengage.mindtap.keywords.PrintPageActions.java

License:Open Source License

public void verifySLAPrintPreview() {
    wait.hardWait(5);/*  w w  w. j a  v a2  s .  c o  m*/
    windowHandle = driver.getWindowHandle();
    ArrayList<String> tabs2 = new ArrayList<String>(driver.getWindowHandles());
    System.out.println(tabs2.size());
    driver.switchTo().window(tabs2.get(1));
    //ReportMsg.info("tab switched");
    //changeWindow(1);
    waitTOSync();
    String Url = driver.getTitle();
    System.out.println(Url);
    WebElement ele = driver.findElement(By.xpath("//button[@class='cancel' and @i18n-content='cancel']"));
    ele.sendKeys(Keys.ESCAPE);
    //switchToPrintPreviewIFrame();

}

From source file:com.cengage.mindtap.keywords.ReadingActivityPageAction.java

public void addTextboxDescription(String desc) {

    // switchToFrame("distinct_activity_create_frame");
    waitTOSync();//from   w  w w. ja va  2  s .  co  m
    waitTOSync();
    waitTOSync();
    switchToFrame("bodyText_ifr");
    WebElement element = driver.findElement(By.id("tinymce"));
    driver.findElement(By.id("tinymce")).clear();
    System.out.println("Editing text box description in text input");
    element.sendKeys(Keys.CONTROL + "b");
    element.sendKeys(desc);
    element.sendKeys(Keys.ENTER);
}

From source file:com.cengage.mindtap.keywords.ReadingActivityPageAction.java

public void addLinkToTextBox() {
    WebElement element = driver.findElement(By.id("tinymce"));

    element.sendKeys("linked text");
    // waitTOSync();
    element.sendKeys(Keys.chord(Keys.SHIFT, Keys.HOME));
    waitTOSync();/*from   w w w.ja v  a 2 s  .c  o  m*/
    waitTOSync();
    switchToDefaultContent();
    waitTOSync();
    switchToFrame(element("modelOptionsEditFrame1"));
    waitTOSync();
    executeJavascript("document.getElementsByClassName('mceIcon mce_link')[0].click();");
    // element("hyperlink").click();
    windowHandle = driver.getWindowHandle();
    ArrayList<String> tabs2 = new ArrayList<String>(driver.getWindowHandles());
    driver.switchTo().window(tabs2.get(1));
    element("linkBox").clear();
    element("linkBox").sendKeys("http://google.com");
    element("linkTitle").clear();
    element("linkTitle").sendKeys("Google");
    element("linkInsert").click();

    waitTOSync();
    driver.switchTo().window(windowHandle);
    System.out.println("window switched");
    switchToDefaultContent();
    switchToFrame(element("modelOptionsEditFrame1"));
    switchToFrame("bodyText_ifr");
    waitTOSync();
    waitTOSync();

    Assert.assertTrue(element("linkedText").isDisplayed(), "text is not linked");
}

From source file:com.cengage.mindtap.keywords.SVRPageActions.java

public void studentSubmitsAnswersToActivity(String answer) {

    switchToMediaName(); //switchToMainIFrame();
    switchToActiveServiceCXPFrame();//from   w ww . j a v  a 2  s. c  o m
    waitForElementPresent("By.xpath(//li[@heading='Questions'])");
    WebElement answerBox;
    for (int i = 0; i < 3; i++) {
        answerBox = driver
                .findElement(By.xpath("//div[@id='section1_assessment1_question_" + i + "']//nobr/textarea"));
        answerBox.click();
        answerBox.clear();
        answerBox.sendKeys(answer);
        waitTOSync();// for answers to be uploaded on SVR server
    }
    element("submitBtn").click();
    for (int i = 1; i < 5; i++) {
        waitTOSync();
    }
    //waitForElementDisplayed(By.xpath("(//div[@class='ci-feedback-title'])[1]"))
    deselectFrame();
}

From source file:com.cengage.mindtap.keywords.youSeeUPageActions.java

private void insertDataInMatrix() {
    int j = 1, k = 1;
    WebElement textBoxLocator, textBoxPoints;
    for (int i = 0; i < 3; i++) {
        while (j < 5) {
            textBoxLocator = driver//from w  w w.  jav a 2  s .c o m
                    .findElement(By.xpath("//textarea[@id='casestudy_designerbundle_rubric_type_rows_" + i
                            + "_cells_" + j + "_description']"));
            textBoxLocator.click();
            textBoxLocator.clear();
            textBoxLocator.sendKeys("automation :" + i + j);

            j += 1;
        }
        while (k < 5) {
            textBoxPoints = driver
                    .findElement(By.xpath("//input[@id='casestudy_designerbundle_rubric_type_rows_" + i
                            + "_cells_" + k + "_points']"));
            textBoxPoints.click();
            textBoxPoints.clear();
            textBoxPoints.sendKeys("10");
            k += 1;
        }

        j = 0;
        k = 1;
    }
}