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.cengage.mtx.keywords.MTXEssayLensActivityPageActions.java

public void enterEssayTextInEditor() {
    switchToFrame("cke_wysiwyg_frame cke_reset");
    waitTOSync();/*from  www  .  j  av  a2s . c o  m*/
    WebElement element = driver.findElement(By.id("cke_56_contents"));
    System.out.println("Entering note description in text input");
    element.sendKeys(Keys.CONTROL + "a");
    element.sendKeys("Instructor created note description");
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

@Override
public void sendKeys(String locator, Keys k) {
    waitForElementFound(locator, FIVE);
    WebElement we = findElement(locator);
    we.sendKeys(k);
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

@Override
public void sendKeys(String locator, String value) {
    try {//from w  w w.j  a  va  2s  .c o m
        waitForElementFound(locator, FIVE);
        WebElement we = findElement(locator);
        we.sendKeys(value);
    } catch (ElementNotVisibleException e) {
        throw new RuntimeException("Unable to send keys to element: " + locator, e);
    }
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

@Override
public void type(String locator, String value) {
    WebElement we = findElement(locator);
    try {// ww  w.j av  a2s.  c  om
        we.click();
    } catch (Exception e) {
    }
    we.clear();
    we.sendKeys(value);
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

@Override
public void typeWithoutClearing(String locator, String value) {
    WebElement we = findElement(locator);
    // try to click otherwise ignore if it fails
    try {/*from w  w w. jav  a 2 s .  c  om*/
        we.click();
    } catch (Exception e) {
    }
    we.sendKeys(value);
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

@Override
public void typeUsingJavascript(String locator, String value) {
    WebElement we = findElement(locator);
    String event = "arguments[0].value=\"" + value + "\";";
    JavascriptExecutor executor = (JavascriptExecutor) webDriver;
    // Try to send keys the normal way but if it it fails, type using javascript
    try {//  w ww  . j  a  v a2s.  co m
        we.sendKeys(value);
    } catch (Exception e) {
        executor.executeScript(event, we);
    }
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

@Override
public void typeUsingRobot(String locator, String value) {
    WebElement we = findElement(locator);
    // try to click otherwise ignore if it fails
    try {//from  ww w .ja  v  a  2 s .c  o m
        we.click();
    } catch (Exception e) {
    }
    ClipboardOwner clipboardOwner = new ClipboardOwner() {
        @Override
        public void lostOwnership(Clipboard clipboard, Transferable contents) {
        }
    };
    Robot robot;
    try {
        robot = new Robot();
        try {
            we.sendKeys(value);
        } catch (Exception e) {
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            StringSelection stringSelection = new StringSelection(value);
            clipboard.setContents(stringSelection, clipboardOwner);
            robot.keyPress(KeyEvent.VK_CONTROL);
            robot.keyPress(KeyEvent.VK_V);
            robot.keyRelease(KeyEvent.VK_V);
            robot.keyRelease(KeyEvent.VK_CONTROL);
        }
    } catch (AWTException e1) {
        e1.printStackTrace();
    }
}

From source file:com.cisco.dbds.utils.primewidgets.primewidgetsStepDef.java

License:Open Source License

@Given("^Scroll down or up$")
public void scroll_down() throws NoSuchMethodException, SecurityException, ClassNotFoundException,
        IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    //   WebElement we = SeleniumUtilities.findElement(Identifier.XPATH, ".//label[normalize-space(text())='Users and Groups']");
    //   WebElement scroll = SeleniumUtilities.findElement(Identifier.XPATH, ".//label[contains(normalize-space(text()),'Users and Groups')]");
    WebElement scroll = primewuipf.SETTINGS_BUTTON_WE_XPATH;
    scroll.sendKeys(Keys.PAGE_UP);
    //   SeleniumUtilities.scroll(we, 100);
    //   WebElement element = driver.findElement(By.id("id_of_element"));
    //   JavascriptExecutor js = (JavascriptExecutor) (SeleniumUtilities.getDriver());
    ((JavascriptExecutor) SeleniumUtilities.getDriver()).executeScript("arguments[0].scrollIntoView(true);",
            scroll);//  w  w w  .  jav  a  2  s.  co m
}

From source file:com.cisco.dbds.utils.selenium.SeleniumUtilities.java

License:Open Source License

/**
 * Performs a type action on the Webelement.
 * /*from w  ww.  j  av  a  2  s. com*/
 * @param element
 *            the element
 * @param contentToSend
 *            the content to send
 */
public static void type(WebElement element, String contentToSend) {
    SeleniumUtilities.waitForElement(element);
    element.sendKeys(contentToSend);
}

From source file:com.cisco.dbds.utils.selenium.SeleniumUtilities.java

License:Open Source License

/**
 * Clear and type./*from  ww w .  j ava  2  s.co  m*/
 * 
 * @param element
 *            the element
 * @param contentToSend
 *            the content to send
 */
public static void clearAndType(WebElement element, String contentToSend) {
    SeleniumUtilities.waitForElement(element);
    SeleniumUtilities.clear(element);
    element.sendKeys(contentToSend);
}