Example usage for org.openqa.selenium Keys LEFT_SHIFT

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

Introduction

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

Prototype

Keys LEFT_SHIFT

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

Click Source Link

Usage

From source file:com.machinepublishers.jbrowserdriver.KeyboardServer.java

License:Apache License

/**
 * {@inheritDoc}/*from   ww w .j a  va2 s . c  o m*/
 */
@Override
public void pressKey(CharSequence key) {
    synchronized (lock) {
        if (!shiftPressed) {
            shiftPressed = Keys.SHIFT.equals(key) || Keys.LEFT_SHIFT.equals(key);
        }
    }
    robot.get().keysPress(key);
}

From source file:com.machinepublishers.jbrowserdriver.KeyboardServer.java

License:Apache License

/**
 * {@inheritDoc}/*from   w  w  w  .j ava 2  s. c  om*/
 */
@Override
public void releaseKey(CharSequence key) {
    synchronized (lock) {
        if (shiftPressed) {
            shiftPressed = !Keys.SHIFT.equals(key) && !Keys.LEFT_SHIFT.equals(key);
        }
    }
    robot.get().keysRelease(key);
}

From source file:com.opera.core.systems.DriverKeysTest.java

License:Apache License

@Test
public void testHoldShift() {
    new Actions(driver).sendKeys("acd").sendKeys(Keys.LEFT_SHIFT + "" + Keys.LEFT + Keys.LEFT).sendKeys("b")
            .build().perform();//from   w  ww  .  ja  v  a 2s. c o m
    assertEquals("ab", fieldOne.getAttribute("value"));
}

From source file:com.opera.core.systems.DriverKeysTest.java

License:Apache License

@Test
public void testMultipleModifiers() throws Exception {
    new Actions(driver).sendKeys("abc defghij").sendKeys(Keys.CONTROL + "" + Keys.LEFT_SHIFT + Keys.LEFT)
            .sendKeys(Keys.BACK_SPACE).build().perform();

    assertEquals("abc ", fieldOne.getAttribute("value"));
}

From source file:org.eclipse.che.selenium.theia.TheiaBuildPluginTest.java

License:Open Source License

@Test
public void pluginShouldBeBuilt() {
    final String pluginNameSearchSequence = "hello-world";
    final String yeomanWizardSearchSequence = ">yeom";
    final String helloWorldPluginProposal = "Hello World plug-in";
    final String goToDirectoryCommand = "cd hello-world";
    final String wsTheiaIdeTerminalTitle = "ws/theia-ide terminal 0";
    final String expectedYaomanMessage = "Yeoman generator successfully ended";
    final String expectedTerminalSuccessOutput = "Packaging of plugin\n" + "\uD83D\uDD0D Validating...?\n"
            + "\uD83D\uDDC2  Getting dependencies...?\n" + "\uD83D\uDDC3  Resolving files...?\n"
            + "?  Excluding files...?\n" + "??  Generating Assembly...?\n"
            + "\uD83C\uDF89 Generated plugin: hello_world.theia";
    final String backendPluginDescription = "Backend plug-in, it will run on the server side.";

    // prepare project tree
    theiaProjectTree.waitFilesTab();/* w  w  w . ja v  a 2 s.  c  o m*/
    theiaProjectTree.clickOnFilesTab();
    theiaIde.waitNotificationDisappearance("Che Workspace: Finished cloning projects.",
            UPDATING_PROJECT_TIMEOUT_SEC);

    // create project by "Yeoman Wizard"
    theiaIde.pressKeyCombination(Keys.LEFT_CONTROL, Keys.LEFT_SHIFT, "p");
    theiaProposalForm.waitForm();
    theiaProposalForm.enterTextToSearchField(yeomanWizardSearchSequence);
    theiaProposalForm.waitProposal("Yeoman Wizard");
    theiaProposalForm.clickOnProposal("Yeoman Wizard");

    try {
        theiaProposalForm.waitForm();
    } catch (TimeoutException ex) {
        // remove try-catch block after issue has been resolved
        fail("Known permanent failure https://github.com/eclipse/che/issues/12315");
    }

    theiaProposalForm.enterTextToSearchField(pluginNameSearchSequence);
    seleniumWebDriverHelper.pressEnter();
    theiaProposalForm.clickOnProposal(backendPluginDescription);
    theiaProposalForm.clickOnProposal(helloWorldPluginProposal);
    theiaIde.waitNotificationMessageContains(expectedYaomanMessage, UPDATING_PROJECT_TIMEOUT_SEC);
    theiaIde.waitNotificationDisappearance(expectedYaomanMessage, UPDATING_PROJECT_TIMEOUT_SEC);

    // build plugin
    openTerminalByProposal("ws/theia-ide");
    theiaTerminal.waitTab(wsTheiaIdeTerminalTitle);
    theiaTerminal.clickOnTab(wsTheiaIdeTerminalTitle);
    theiaTerminal.performCommand(goToDirectoryCommand);
    theiaTerminal.waitTerminalOutput(goToDirectoryCommand, 0);
    theiaTerminal.clickOnTab(wsTheiaIdeTerminalTitle);
    theiaTerminal.waitTabSelected(wsTheiaIdeTerminalTitle);
    theiaTerminal.performCommand("yarn");
    try {
        theiaTerminal.waitTerminalOutput(expectedTerminalSuccessOutput, 0);
    } catch (TimeoutException ex) {
        // remove try-catch block after issue has been resolved
        fail("Known permanent failure https://github.com/eclipse/che/issues/11624", ex);
    }
}

From source file:org.eclipse.che.selenium.theia.TheiaBuildPluginTest.java

License:Open Source License

@Test(priority = 1)
public void hostedModeShouldWork() {
    final String projectName = "hello-world";
    final String hostedSearchSequence = ">hosted";
    final String editedSourceFile = "hello-world-backend.ts";
    final String expectedHelloWorldNotification = "Hello World!";
    final String expectedAlohaWorldNotification = "Aloha World!";
    final String suggestionForSelection = "Hosted Plugin: Start Instance";
    final String helloWorldProposal = "Hello World";
    final String helloWorldSearchSequence = ">Hello";
    final String expectedInstanceRunningMessage = "Hosted instance is running at:";
    final String parentWindow = seleniumWebDriver.getWindowHandle();
    final String expectedPluginFolderMessage = "Plugin folder is set to: file:///projects/hello-world";
    final String expectedStartingServerMessage = "Starting hosted instance server ...";
    final String editedSourceLine = "theia.window.showInformationMessage('Aloha World!');";
    final String expectedTextAfterDeleting = "context.subscriptions.push(theia.commands.registerCommand(informationMessageTestCommand, (...args: any[]) => {\n"
            + " \n" + "    }));";

    // run hosted mode
    theiaProjectTree.waitItem(projectName);
    theiaProjectTree.clickOnItem(projectName);
    theiaProjectTree.waitItemSelected(projectName);
    theiaIde.pressKeyCombination(Keys.LEFT_CONTROL, Keys.LEFT_SHIFT, "p");
    theiaProposalForm.waitForm();/*  w w  w  . j av  a 2s  .  co m*/
    theiaProposalForm.enterTextToSearchField(hostedSearchSequence);
    theiaProposalForm.clickOnProposal(suggestionForSelection);
    hostedPluginSelectPathForm.waitForm();
    hostedPluginSelectPathForm.clickOnProjectItem(projectName);
    hostedPluginSelectPathForm.waitProjectItemSelected(projectName);
    hostedPluginSelectPathForm.clickOnOpenButton();
    hostedPluginSelectPathForm.waitFormClosed();
    waitNotificationEqualsTo(expectedPluginFolderMessage, parentWindow);
    waitNotificationEqualsTo(expectedStartingServerMessage, parentWindow);
    waitNotificationContains(expectedInstanceRunningMessage, parentWindow);

    // check hosted mode availability
    switchToNonParentWindow(parentWindow);
    waitHostedPageReady();
    theiaProjectTree.clickOnFilesTab();
    theiaProjectTree.waitProjectAreaOpened();
    theiaProjectTree.waitItem(projectName);

    // check plugin output
    theiaIde.pressKeyCombination(Keys.LEFT_CONTROL, Keys.LEFT_SHIFT, "p");
    theiaProposalForm.waitSearchField();
    theiaProposalForm.enterTextToSearchField(helloWorldSearchSequence);
    theiaProposalForm.clickOnProposal(helloWorldProposal);
    theiaIde.waitNotificationEqualsTo(expectedHelloWorldNotification);
    theiaIde.waitNotificationDisappearance(expectedHelloWorldNotification);

    // check editing of the source code
    switchToParentWindow(parentWindow);
    theiaProjectTree.waitProjectAreaOpened();
    theiaProjectTree.waitItem(projectName);
    theiaProjectTree.expandPathAndOpenFile(projectName + "/src", editedSourceFile);
    theiaEditor.waitEditorTab(editedSourceFile);
    theiaEditor.waitTabSelecting(editedSourceFile);
    theiaEditor.waitActiveEditor();
    theiaEditor.selectLineText(14);
    seleniumWebDriverHelper.pressDelete();
    theiaEditor.waitEditorText(expectedTextAfterDeleting);
    theiaEditor.enterTextByTypingEachChar(editedSourceLine);
    theiaEditor.waitEditorText(editedSourceLine);
    theiaEditor.waitTabSavedStatus(editedSourceFile);

    // check applying of the changes in hosted mode window
    switchToNonParentWindow(parentWindow);
    waitHostedPageReady();
    seleniumWebDriver.navigate().refresh();
    waitHostedPageReady();
    theiaProjectTree.waitProjectAreaOpened();
    theiaProjectTree.waitItem(projectName);
    theiaIde.pressKeyCombination(Keys.LEFT_CONTROL, Keys.LEFT_SHIFT, "p");
    theiaProposalForm.waitSearchField();
    theiaProposalForm.enterTextToSearchField(helloWorldSearchSequence);
    theiaProposalForm.clickOnProposal(helloWorldProposal);
    theiaIde.waitNotificationEqualsTo(expectedAlohaWorldNotification);
    theiaIde.waitNotificationDisappearance(expectedAlohaWorldNotification);
}

From source file:org.safs.selenium.webdriver.lib.WDLibrary.java

License:Open Source License

/**
 *
 * @param key Keys, the selenium Keys value
 * @return int the value of java KeyEvent
 * @throws SeleniumPlusException//from   w ww .  ja v  a2s  .  c o m
 */
static int toJavaKeyCode(Keys key) throws SeleniumPlusException {
    String debugmsg = StringUtils.debugmsg(WDLibrary.class, "toJavaKeyCode");
    if (Keys.SHIFT.equals(key))
        return KeyEvent.VK_SHIFT;
    else if (Keys.LEFT_SHIFT.equals(key))
        return KeyEvent.VK_SHIFT;
    else if (Keys.CONTROL.equals(key))
        return KeyEvent.VK_CONTROL;
    else if (Keys.LEFT_CONTROL.equals(key))
        return KeyEvent.VK_CONTROL;
    else if (Keys.ALT.equals(key))
        return KeyEvent.VK_ALT;
    else if (Keys.LEFT_ALT.equals(key))
        return KeyEvent.VK_ALT;
    else {
        String msg = " No handled key '" + (key == null ? "null" : key.toString()) + "'.";
        IndependantLog.debug(debugmsg + msg);
        throw new SeleniumPlusException(msg);
    }
}