Example usage for org.openqa.selenium Keys SHIFT

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

Introduction

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

Prototype

Keys SHIFT

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

Click Source Link

Usage

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

public void editNote() throws AWTException {
    waitTOSync();//from  w w  w. ja v  a  2  s . 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 addLinkToTextBox() {
    WebElement element = driver.findElement(By.id("tinymce"));

    element.sendKeys("linked text");
    // waitTOSync();
    element.sendKeys(Keys.chord(Keys.SHIFT, Keys.HOME));
    waitTOSync();/*from  ww w  . ja  va 2 s  .  c om*/
    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.codenvy.ide.operation.java.JavaFoldSelectionTest.java

License:Open Source License

@Test
public void foldPartOfComment() throws Exception {
    IDE.JAVAEDITOR.waitJavaEditorIsActive();
    IDE.PROGRESS_BAR.waitProgressBarControlClose();
    // select fold part of the comment.
    IDE.GOTOLINE.goToLine(4);/*from w ww  . j a  v a2s .co  m*/
    IDE.JAVAEDITOR.waitJavaEditorIsActive();
    // select 4 lines of the comment
    for (int i = 0; i < 4; i++) {
        IDE.JAVAEDITOR.typeTextIntoJavaEditor(Keys.SHIFT.toString() + Keys.ARROW_DOWN);
    }

    // fold selected lines from context menu
    IDE.JAVAEDITOR.callContextMenuIntoJavaEditor();
    IDE.CONTEXT_MENU.waitOpened();
    IDE.CONTEXT_MENU.waitWhileCommandIsEnabled("Fold Selection");
    IDE.CONTEXT_MENU.runCommand("Fold Selection");
    IDE.CONTEXT_MENU.waitClosed();

    // check that selected text is folded and expand button appear in right line
    IDE.JAVAEDITOR.waitWhileJavaEditorWillContainSpecifiedText(FOLDED_PART_OF_COMMENT);
    IDE.JAVAEDITOR.waitGutterExpandButtonInSpecifiedLineNumber(4);
    IDE.JAVAEDITOR.waitExpandButtonInSpecifiedLineNumber(4);

    // expand folded text and check content
    IDE.JAVAEDITOR.clickOnExpandButtonInSpecifiedLineNumber(4);
    IDE.JAVAEDITOR.waitWhileJavaEditorWillContainSpecifiedText(FILE_CONTENT);
}

From source file:com.codenvy.ide.operation.java.JavaFoldSelectionTest.java

License:Open Source License

@Test
public void foldFewMethods() throws Exception {
    IDE.JAVAEDITOR.waitJavaEditorIsActive();

    // select and fold few methods
    IDE.GOTOLINE.goToLine(35);/* w  w  w.j  av a 2 s .  c o  m*/

    // select 4 lines of the comment
    for (int i = 0; i < 9; i++) {
        IDE.JAVAEDITOR.typeTextIntoJavaEditor(Keys.SHIFT.toString() + Keys.ARROW_DOWN);
    }

    IDE.MENU.runCommand(MenuCommands.Edit.EDIT_MENU, MenuCommands.Edit.FOLD_SELECTION);

    // check that selected text is folded and expand button appear in right line
    IDE.JAVAEDITOR.waitWhileJavaEditorWillContainSpecifiedText(FOLDED_FEW_METHODS);
    IDE.JAVAEDITOR.waitGutterExpandButtonInSpecifiedLineNumber(35);
    IDE.JAVAEDITOR.waitExpandButtonInSpecifiedLineNumber(35);

    // expand folding and check content
    IDE.JAVAEDITOR.clickOnExpandButtonInSpecifiedLineNumber(35);
    IDE.JAVAEDITOR.waitWhileJavaEditorWillContainSpecifiedText(FILE_CONTENT);
}

From source file:com.codenvy.ide.operation.java.JavaFoldSelectionTest.java

License:Open Source License

@Test
public void foldPartOfCommentAndCode() throws Exception {
    IDE.JAVAEDITOR.waitJavaEditorIsActive();

    // select and fold few methods
    IDE.GOTOLINE.goToLine(6);// www.  j  a v  a 2s .  c o m

    // select 4 lines of the comment
    for (int i = 0; i < 20; i++) {
        IDE.JAVAEDITOR.typeTextIntoJavaEditor(Keys.SHIFT.toString() + Keys.ARROW_DOWN);
    }

    IDE.MENU.runCommand(MenuCommands.Edit.EDIT_MENU, MenuCommands.Edit.FOLD_SELECTION);

    // check that selected text is folded and expand button appear in right line
    IDE.JAVAEDITOR.waitWhileJavaEditorWillContainSpecifiedText(FOLDED_PART_OF_COMMENT_AND_CODE);
    IDE.JAVAEDITOR.waitGutterExpandButtonInSpecifiedLineNumber(6);
    IDE.JAVAEDITOR.waitExpandButtonInSpecifiedLineNumber(6);

    // expand folding and check content
    IDE.JAVAEDITOR.clickOnExpandButtonInSpecifiedLineNumber(6);
    IDE.JAVAEDITOR.waitWhileJavaEditorWillContainSpecifiedText(FILE_CONTENT);
}

From source file:com.codenvy.ide.operation.java.JavaFoldSelectionTest.java

License:Open Source License

@Test
public void foldPartOfImportsAndCode() throws Exception {
    IDE.JAVAEDITOR.waitJavaEditorIsActive();
    IDE.GOTOLINE.goToLine(15);/*  w  ww  .  ja v  a  2  s  .com*/

    // select 10 lines of the code include imports and part of code
    for (int i = 0; i < 10; i++) {
        IDE.JAVAEDITOR.typeTextIntoJavaEditor(Keys.SHIFT.toString() + Keys.ARROW_DOWN);
    }

    // call fold selection from edit menu
    IDE.MENU.runCommand(MenuCommands.Edit.EDIT_MENU, MenuCommands.Edit.FOLD_SELECTION);

    // check that selected text is folded and expand button appear in right line
    IDE.JAVAEDITOR.waitWhileJavaEditorWillContainSpecifiedText(FOLDED_PART_OF_IMPORTS_AND_CODE);
    IDE.JAVAEDITOR.waitGutterExpandButtonInSpecifiedLineNumber(15);
    IDE.JAVAEDITOR.waitExpandButtonInSpecifiedLineNumber(15);

    // expand folded text and check content
    IDE.JAVAEDITOR.clickOnGutterExpandButtonInSpecifiedLineNumber(15);
    IDE.JAVAEDITOR.waitWhileJavaEditorWillContainSpecifiedText(FILE_CONTENT);

    // collapse folding and check that expand button appear
    IDE.JAVAEDITOR.waitGutterCollapseButtonInSpecifiedLineNumber(15);
    IDE.JAVAEDITOR.clickOnGutterCollapseButtonInSpecifiedLineNumber(15);
    IDE.JAVAEDITOR.waitWhileJavaEditorWillContainSpecifiedText(FOLDED_PART_OF_IMPORTS_AND_CODE);

    IDE.JAVAEDITOR.waitGutterExpandButtonInSpecifiedLineNumber(15);
    IDE.JAVAEDITOR.waitExpandButtonInSpecifiedLineNumber(15);

    // expand folding
    IDE.JAVAEDITOR.clickOnExpandButtonInSpecifiedLineNumber(15);
    IDE.JAVAEDITOR.waitWhileJavaEditorWillContainSpecifiedText(FILE_CONTENT);

    //
    // repeat same case but with different number of the selected lines
    //

    reopenForFirefox();

    IDE.GOTOLINE.goToLine(15);
    IDE.STATUSBAR.waitCursorPositionAt("15 : 1");
    // select 9 lines of the code include imports and part of code
    for (int i = 0; i < 8; i++) {
        IDE.JAVAEDITOR.typeTextIntoJavaEditor(Keys.SHIFT.toString() + Keys.ARROW_DOWN);
    }

    // call fold selection from edit menu
    IDE.MENU.runCommand(MenuCommands.Edit.EDIT_MENU, MenuCommands.Edit.FOLD_SELECTION);

    // check that selected text is folded and expand button appear in right line
    IDE.JAVAEDITOR.waitWhileJavaEditorWillContainSpecifiedText(FOLDED_PART_OF_IMPORTS_AND_CODE_2);
    IDE.JAVAEDITOR.waitGutterExpandButtonInSpecifiedLineNumber(15);
    IDE.JAVAEDITOR.waitExpandButtonInSpecifiedLineNumber(15);

    // expand folded text and check content
    IDE.JAVAEDITOR.clickOnGutterExpandButtonInSpecifiedLineNumber(15);
    IDE.JAVAEDITOR.waitWhileJavaEditorWillContainSpecifiedText(FILE_CONTENT);

    // collapse folding and check that expand button appear
    IDE.JAVAEDITOR.waitGutterCollapseButtonInSpecifiedLineNumber(15);
    IDE.JAVAEDITOR.clickOnGutterCollapseButtonInSpecifiedLineNumber(15);
    IDE.JAVAEDITOR.waitWhileJavaEditorWillContainSpecifiedText(FOLDED_PART_OF_IMPORTS_AND_CODE_2);

    IDE.JAVAEDITOR.waitGutterExpandButtonInSpecifiedLineNumber(15);
    IDE.JAVAEDITOR.waitExpandButtonInSpecifiedLineNumber(15);

    // expand folding
    IDE.JAVAEDITOR.clickOnExpandButtonInSpecifiedLineNumber(15);
    IDE.JAVAEDITOR.waitWhileJavaEditorWillContainSpecifiedText(FILE_CONTENT);
}

From source file:com.coderoad.automation.common.util.old.BasePage.java

License:Open Source License

/**
 * Clear text.
 * 
 * @param fieldName the field name
 */
protected void clearText(WebElement fieldName) {

    fieldName.sendKeys(Keys.SHIFT, Keys.HOME, Keys.BACK_SPACE);
}

From source file:com.coderoad.automation.common.util.old.BasePage.java

License:Open Source License

public String getVersion(Enum<Modules> portal) {
    String response = null;/*from  w ww .  j av  a  2 s . c om*/
    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

/**
 * Selects text in the text area between indices provided as parameters.
 *
 * @param startPos the beginning position
 * @param endPos   the ending position/*  w ww.j a  va2s.c o  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.digi.selenium.util.common.PageNavigation.java

protected void socialLinks() {

    try {//from   w  ww. ja  v a 2  s.  co  m

        JavascriptExecutor jse = (JavascriptExecutor) getDriver();
        jse.executeScript("window.scrollBy(0,1200)", "");
        //                 WebElement fb = (new WebDriverWait(fbdriver, 5000)).until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='main']/section/div/ul/li[1]/a")));
        //           fb.click();
        //*[@id="main"]/section/div/ul/li[1]/a
        for (int i = 1; i <= 3; i++) {
            WebElement socialbtn = getDriver()
                    .findElement(By.xpath("//*[@id='main']/section/div/ul/li[" + i + "]/a"));
            Actions newTab1 = new Actions(getDriver());
            newTab1.keyDown(Keys.SHIFT).click(socialbtn).keyUp(Keys.SHIFT).build().perform();
            Thread.sleep(500);

            //handle windows change
            String base1 = getDriver().getWindowHandle();
            Set<String> set1 = getDriver().getWindowHandles();

            set1.remove(base1);
            assert set1.size() == 1;
            getDriver().switchTo().window((String) set1.toArray()[0]);
            waitForPageLoad(500);
            //wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='blueBarNAXAnchor']/div/div/div/div[1]/h1/a/i")));
            //close the window
            getDriver().close();
            getDriver().switchTo().window(base1);

            // handle windows change and switch back to the main window
            Thread.sleep(500);
            for (String winHandle1 : getDriver().getWindowHandles()) {
                getDriver().switchTo().window(winHandle1);

                System.out.println("Link Validation for :" + socialbtn.getText() + " --> Passed");
                log.info("Link Validation for :" + socialbtn.getText() + " --> Passed");
                Thread.sleep(500);
            }
        }
        JavascriptExecutor jse1 = (JavascriptExecutor) getDriver();
        jse1.executeScript("window.scrollBy(0,-1200)", "");
        // jse1.executeScript("window.scrollTo(0,document.body.scrollHeight", "");
        Thread.sleep(500);
    }

    catch (Exception e) {
        log.error("Failed to verify Social Media Links shutting down");
        shutDown();
    }

}