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:library.functions.CommonFunctions.java

License:Open Source License

public void actionType(By by, String value) throws InterruptedException {
    waitForPageObject((by));//from   w w  w.  j a v  a  2  s  .  com
    new Actions(getWebDriver()).moveToElement(getWebDriver().findElement(by)).click()
            .sendKeys(Keys.chord(Keys.CONTROL, "a"), value).perform();
}

From source file:loblaw.provisioning.TicketCreator.java

private void createTicket() {
    try {//from   w ww .j  av a 2s  .  co  m

        //   WebElement templateDropdown = (new WebDriverWait(activeBrowser, 10)).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id=\"reqTemplateListh\"]/p/span")));
        //  templateDropdown.click();
        //WebElement loblawLine = (new WebDriverWait(activeBrowser, 10)).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id=\"reqTemplateList\"]/div/table/tbody/tr/td/ul/li[45]/a")));
        //loblawLine.click();
        Thread.sleep(300);
        WebElement contactName = (new WebDriverWait(activeBrowser, 10)) //added this line
                .until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id=\"reqSearch\"]")));
        contactName.sendKeys("Loblaw");

        WebElement storeNumberArea = (new WebDriverWait(activeBrowser, 10)
                .until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id=\"UDF_CHAR2\"]"))));
        storeNumberArea.clear();
        storeNumberArea.sendKeys(storeNumberText);

        WebElement titleArea = (new WebDriverWait(activeBrowser, 10))
                .until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id=\"title\"]")));
        //title format: Loblaw New Site Provisioning - SiteID: [Banner] [Location ID] [Line of Business]
        titleArea.clear();
        titleArea.sendKeys(ticketTitleText);

        WebElement descriptionArea = (new WebDriverWait(activeBrowser, 10)).until(
                ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id=\"zEditor\"]/div/iframe")));
        descriptionArea.sendKeys(Keys.chord(Keys.CONTROL, "a"));
        descriptionArea.sendKeys(ticketDumpText);

        WebElement addRequestButton = (new WebDriverWait(activeBrowser, 10))
                .until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id=\"buttonType\"]")));
        addRequestButton.click();
        Thread.sleep(2000);

    } catch (Exception e) {

        System.out.println("Trying to create ticket, got error:");
        System.out.println(e.getMessage());
    }
}

From source file:objective.taskboard.it.AbstractUIIntegrationTest.java

License:Open Source License

protected void switchToFirstTab() {
    webDriver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL + "\t");
    ArrayList<String> tabs = new ArrayList<>(webDriver.getWindowHandles());
    webDriver.switchTo().window(tabs.get(0));
}

From source file:objective.taskboard.it.MainPage.java

License:Open Source License

public MainPage typeSearch(String searchValue) {
    searchIssuesInput.sendKeys(Keys.CONTROL, "a");
    searchIssuesInput.sendKeys(Keys.DELETE);
    searchIssuesInput.sendKeys(searchValue);
    waitUntil(textToBePresentInElementValue(searchIssuesInput, searchValue));
    return this;
}

From source file:objective.taskboard.it.MainPage.java

License:Open Source License

public MainPage clearSearch() {
    searchIssuesInput.sendKeys(Keys.CONTROL, "a");
    searchIssuesInput.sendKeys(Keys.DELETE);
    waitUntil(textToBePresentInElementValue(searchIssuesInput, ""));
    return this;
}

From source file:org.alfresco.po.PageElement.java

License:Open Source License

/**
 * Returns COMMAND {@link Keys} if the OS is MAC OS X else CONTROL key.
 * @return {@link Keys}//from w w  w.ja va  2  s  .c  o  m
 */
private Keys getOsKey() {
    Keys keys = Keys.CONTROL;
    String osName = System.getProperty("os.name");
    if (osName != null && !osName.isEmpty() && osName.toLowerCase().startsWith("mac")) {
        keys = Keys.COMMAND;
    }
    return keys;
}

From source file:org.alfresco.po.share.site.wiki.WikiPage.java

License:Open Source License

/**
 * Copy Image using CTRL+C/*  ww w . j  av a  2s .  c  om*/
 */
public void copyImageFromLib() {
    try {
        driver.switchTo().defaultContent();
        driver.switchTo().frame(WIKI_FORMAT_IFRAME);
        WebElement element = findAndWait(By.cssSelector("#tinymce>p>img"));
        element.sendKeys(Keys.chord(Keys.CONTROL, "a"));
        element.sendKeys(Keys.chord(Keys.CONTROL, "c"));
        driver.switchTo().defaultContent();
    } catch (TimeoutException toe) {
        logger.error("Time out finding image", toe);
    }
}

From source file:org.alfresco.po.share.site.wiki.WikiPage.java

License:Open Source License

/**
 * Pasting image using CTRL+V//from  ww  w  .j  a  v  a 2  s  . co m
 */
public void pasteImageOnEditor() {
    try {
        driver.switchTo().defaultContent();
        driver.switchTo().frame(WIKI_FORMAT_IFRAME);
        WebElement element = findAndWait(By.cssSelector("#tinymce"));
        element.sendKeys(Keys.chord(Keys.CONTROL, "v"));
        element.sendKeys(Keys.chord(Keys.CONTROL, "v"));
        driver.switchTo().defaultContent();
    } catch (TimeoutException toe) {
        logger.error("Time out finding image", toe);
    }
}

From source file:org.auraframework.components.ui.InputCutCopyPasteUITest.java

License:Apache License

@ExcludeBrowsers({ BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE,
        BrowserType.SAFARI })/*from   w  w w  .  j a  va  2s.  c o m*/
public void testCutCopyPasteEvents() throws Exception {
    if (System.getProperty("os.name").startsWith("Mac")) {
        // Selenium's key event injection are simulated for OSX, and not actually received by
        // the real browser (see https://code.google.com/p/selenium/issues/detail?id=3101),
        // which means that there's no way to generate cut/copy/paste events under Selenium.
        // So, on Mac, skip this whole test. No, changing Keys.CONTROL to Keys.COMMAND below
        // doesn't do it, they aren't "real keypresses" to the browser at all.
        return;
    }

    WebDriver d = getDriver();
    open("/uitest/inputCutCopyPasteEventTest.cmp");
    WebElement input = d.findElement(By.xpath("//input"));
    WebElement output = d.findElement(By.xpath("//span[@class='uiOutputText']"));
    input.click();
    input.sendKeys(Keys.CONTROL, "a");

    // Fire Copy Event
    String copyValueExpression = auraUITestingUtil.getValueFromRootExpr("v.copyEventFired");
    copyValueExpression = auraUITestingUtil.prepareReturnStatement(copyValueExpression);
    assertFalse("Copy event should not have been triggered yet",
            auraUITestingUtil.getBooleanEval(copyValueExpression));
    input.sendKeys(Keys.CONTROL, "c");
    assertTrue("Copy event should have been triggered", auraUITestingUtil.getBooleanEval(copyValueExpression));
    waitForElementTextPresent(output, "Copy Event Fired");

    // Fire Cut Event
    String cutValueExpression = auraUITestingUtil.getValueFromRootExpr("v.cutEventFired");
    cutValueExpression = auraUITestingUtil.prepareReturnStatement(cutValueExpression);
    assertFalse("Cut event should not have been triggered yet",
            auraUITestingUtil.getBooleanEval(cutValueExpression));
    input.sendKeys(Keys.CONTROL, "a");
    input.sendKeys(Keys.CONTROL, "x");
    assertTrue("Cut event should have been triggered", auraUITestingUtil.getBooleanEval(cutValueExpression));
    waitForElementTextPresent(output, "Cut Event Fired");

    // Fire Paste Event
    String pasteValueExpression = auraUITestingUtil.getValueFromRootExpr("v.pasteEventFired");
    pasteValueExpression = auraUITestingUtil.prepareReturnStatement(pasteValueExpression);
    assertFalse("Paste event should not have been triggered yet",
            auraUITestingUtil.getBooleanEval(pasteValueExpression));
    input.click();
    input.sendKeys(Keys.CONTROL, "v");
    assertTrue("Paste event should have been triggered",
            auraUITestingUtil.getBooleanEval(pasteValueExpression));
    waitForElementTextPresent(output, "Paste Event Fired");
}

From source file:org.auraframework.integration.test.components.ui.inputText.InputCutCopyPasteUITest.java

License:Apache License

@ExcludeBrowsers({ BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE,
        BrowserType.SAFARI })// w  w w.  j  a v  a 2  s . co  m
@Test
public void testCutCopyPasteEvents() throws Exception {
    if (System.getProperty("os.name").startsWith("Mac")) {
        // Selenium's key event injection are simulated for OSX, and not actually received by
        // the real browser (see https://code.google.com/p/selenium/issues/detail?id=3101),
        // which means that there's no way to generate cut/copy/paste events under Selenium.
        // So, on Mac, skip this whole test. No, changing Keys.CONTROL to Keys.COMMAND below
        // doesn't do it, they aren't "real keypresses" to the browser at all.
        return;
    }

    WebDriver d = getDriver();
    open("/uitest/inputText_CutCopyPasteEventTest.cmp");
    WebElement input = d.findElement(By.xpath("//input"));
    By outputLocator = By.xpath("//span[@class='uiOutputText']");
    input.click();
    input.sendKeys(Keys.CONTROL, "a");

    // Fire Copy Event
    String copyValueExpression = getAuraUITestingUtil().getValueFromRootExpr("v.copyEventFired");
    copyValueExpression = getAuraUITestingUtil().prepareReturnStatement(copyValueExpression);
    assertFalse("Copy event should not have been triggered yet",
            getAuraUITestingUtil().getBooleanEval(copyValueExpression));
    input.sendKeys(Keys.CONTROL, "c");
    assertTrue("Copy event should have been triggered",
            getAuraUITestingUtil().getBooleanEval(copyValueExpression));
    getAuraUITestingUtil().waitForElementText(By.xpath("//span[@class='uiOutputText']"), "Copy Event Fired",
            true);

    // Fire Cut Event
    String cutValueExpression = getAuraUITestingUtil().getValueFromRootExpr("v.cutEventFired");
    cutValueExpression = getAuraUITestingUtil().prepareReturnStatement(cutValueExpression);
    assertFalse("Cut event should not have been triggered yet",
            getAuraUITestingUtil().getBooleanEval(cutValueExpression));
    input.sendKeys(Keys.CONTROL, "a");
    input.sendKeys(Keys.CONTROL, "x");
    assertTrue("Cut event should have been triggered",
            getAuraUITestingUtil().getBooleanEval(cutValueExpression));
    getAuraUITestingUtil().waitForElementText(By.xpath("//span[@class='uiOutputText']"), "Cut Event Fired",
            true);

    // Fire Paste Event
    String pasteValueExpression = getAuraUITestingUtil().getValueFromRootExpr("v.pasteEventFired");
    pasteValueExpression = getAuraUITestingUtil().prepareReturnStatement(pasteValueExpression);
    assertFalse("Paste event should not have been triggered yet",
            getAuraUITestingUtil().getBooleanEval(pasteValueExpression));
    input.click();
    input.sendKeys(Keys.CONTROL, "v");
    assertTrue("Paste event should have been triggered",
            getAuraUITestingUtil().getBooleanEval(pasteValueExpression));
    getAuraUITestingUtil().waitForElementText(outputLocator, "Paste Event Fired", true);
}