Example usage for org.openqa.selenium Keys CONTROL

List of usage examples for org.openqa.selenium Keys CONTROL

Introduction

In this page you can find the example usage for org.openqa.selenium Keys CONTROL.

Prototype

Keys CONTROL

To view the source code for org.openqa.selenium Keys CONTROL.

Click Source Link

Usage

From source file:com.atanas.kanchev.testframework.selenium.handlers.Interact.java

License:Apache License

/**
 * {@inheritDoc}/* w w  w .java 2  s .c om*/
 */
@Override
public Interact paste() {
    ((SeleniumContext<WebDriver>) context().getCurrentContext()).getCurrentElement()
            .sendKeys(Keys.chord(Keys.CONTROL, "v"));
    return this;
}

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

public void AddNote(String note) {
    waitTOSync();/* www.  ja  v  a 2  s.co  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 ww.  j av  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.ReadingActivityPageAction.java

public void addTextboxDescription(String desc) {

    // switchToFrame("distinct_activity_create_frame");
    waitTOSync();//from  ww  w . ja  v a  2s . c om
    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.mtx.keywords.MTXEssayLensActivityPageActions.java

public void enterEssayTextInEditor() {
    switchToFrame("cke_wysiwyg_frame cke_reset");
    waitTOSync();//from  www.  j a  va2  s .  co 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.coderoad.automation.common.util.old.BasePage.java

License:Open Source License

public String getVersion(Enum<Modules> portal) {
    String response = null;/* w ww.j  a  va  2  s  . co m*/
    try {
        if (portal == Modules.CONSUMER_MENU) {
            WebElement html = driver.findElement(By.tagName("html"));
            Assert.assertTrue("The page is not displayed.", html != null);
            String selectAll = Keys.chord(Keys.CONTROL, Keys.SHIFT, "v");
            html.sendKeys(selectAll);
            Alert alertVersion = driver.switchTo().alert();
            response = alertVersion.getText().split(":")[1];
            alertVersion.accept();
        } else if (portal == Modules.MOBILE_PORTAL) {
            WebElement element = driver.findElement(By.xpath("//div[contains(@class, 'site-version')]"));
            Actions actions = new Actions(driver);
            Action doubleClick = actions.doubleClick(element).build();
            doubleClick.perform();
            Alert alertVersion = driver.switchTo().alert();
            response = alertVersion.getText();
            alertVersion.accept();
        }

    } catch (Exception e) {
        e.printStackTrace();
        response = null;
    }
    return response;
}

From source file:com.cognifide.qa.bb.aem.dialog.classic.field.AemRichText.java

License:Apache License

/**
 * Clears the content of richtext's text area.
 *
 * @return This instance./*from www .jav a  2  s .c  om*/
 */
public AemRichText clear() {
    switchToTextArea();
    try {
        bobcatWait.withTimeout(Timeouts.BIG).until(driver -> {
            actions.sendKeys(Keys.chord(Keys.CONTROL, "a")).sendKeys(Keys.BACK_SPACE).sendKeys(Keys.BACK_SPACE)
                    .perform();
            WebElement activeElement = webDriver.switchTo().activeElement();
            String text = activeElement.getText();
            return text.isEmpty();
        }, 2);
        return this;
    } finally {
        frameSwitcher.switchBack();
    }
}

From source file:com.cognifide.qa.bb.aem.dialog.classic.field.AemRichText.java

License:Apache License

/**
 * Selects all text from the text area./*from w ww.  ja  v  a 2  s.c  o  m*/
 *
 * @return This instance.
 */
public AemRichText selectAll() {
    switchToTextArea();
    try {
        actions.sendKeys(Keys.chord(Keys.CONTROL, "a")).perform();
        return this;
    } finally {
        frameSwitcher.switchBack();
    }
}

From source file:com.cognifide.qa.bb.aem.dialog.classic.field.AemRichText.java

License:Apache License

/**
 * Selects text in the text area between indices provided as parameters.
 *
 * @param startPos the beginning position
 * @param endPos   the ending position//from   w ww  . j  a va  2 s  .co  m
 * @return This instance.
 */
public AemRichText selectText(int startPos, int endPos) {
    switchToTextArea();
    try {
        actions.sendKeys(Keys.chord(Keys.CONTROL, Keys.HOME)).perform();
        for (int i = 0; i < startPos; i++) {
            actions.sendKeys(Keys.ARROW_RIGHT).perform();
        }
        actions.keyDown(Keys.SHIFT);
        for (int i = 0; i < endPos - startPos; i++) {
            actions.sendKeys(Keys.ARROW_RIGHT);
        }
        actions.keyUp(Keys.SHIFT).perform();
        return this;
    } finally {
        frameSwitcher.switchBack();
    }
}

From source file:com.cognifide.qa.bb.aem.touch.pageobjects.touchui.dialogfields.text.ControlToolbar.java

License:Apache License

/**
 * Performs 'select all text' action.
 */
public void selectText() {
    actions.keyDown(Keys.CONTROL).sendKeys("a").perform();
}