Example usage for org.openqa.selenium.interactions Actions keyUp

List of usage examples for org.openqa.selenium.interactions Actions keyUp

Introduction

In this page you can find the example usage for org.openqa.selenium.interactions Actions keyUp.

Prototype

public Actions keyUp(CharSequence key) 

Source Link

Document

Performs a modifier key release.

Usage

From source file:be.rubus.web.testing.AbstractWidget.java

License:Apache License

protected void click(WebElement element, Keys... keys) {
    Actions builder = new Actions(driver);

    for (Keys key : keys) {
        builder.keyDown(key);/*  w ww.j a v a  2 s  .  c o m*/
    }
    builder.click(element);
    for (Keys key : keys) {
        builder.keyUp(key);
    }

    Action action = builder.build();

    action.perform();
}

From source file:com.consol.citrus.selenium.actions.DropDownSelectAction.java

License:Apache License

@Override
protected void execute(WebElement webElement, SeleniumBrowser browser, TestContext context) {
    super.execute(webElement, browser, context);

    Select dropdown = new Select(webElement);

    if (StringUtils.hasText(option)) {
        dropdown.selectByValue(context.replaceDynamicContentInString(option));
    }//from w  w w .  j  ava2 s. co m

    if (!CollectionUtils.isEmpty(options)) {
        if (BrowserType.IE.equals(browser.getEndpointConfiguration().getBrowserType())) {
            for (String option : options) {
                dropdown.selectByValue(context.replaceDynamicContentInString(option));
            }
        } else {
            List<WebElement> optionElements = dropdown.getOptions();
            Actions builder = new Actions(browser.getWebDriver());
            builder.keyDown(Keys.CONTROL);
            for (String optionValue : options) {
                for (WebElement option : optionElements) {
                    if (!option.isSelected()
                            && isSameValue(option, context.replaceDynamicContentInString(optionValue))) {
                        builder.moveToElement(option).click(option);
                    }
                }
            }
            builder.keyUp(Keys.CONTROL);
            Action multiple = builder.build();
            multiple.perform();
        }
    }
}

From source file:com.consol.citrus.selenium.client.WebClient.java

License:Apache License

/**
 * Select multiple items from a pull-down list.
 *
 * @param by//www  . j a  v  a  2  s  .  c om
 * @param from Start at index.
 * @param to End at index.
 */
public void selectMultipleItems(By by, int from, int to) {
    Select dropdown = new Select(findElement(by));

    if (BrowserTypeEnum.INTERNET_EXPLORER.equals(browserType)) {
        for (int i = from; i < to; i++) {
            dropdown.selectByIndex(i);
        }
    } else {
        //Rest:
        List<WebElement> options = dropdown.getOptions();
        Actions builder = new Actions(webDriver);
        builder.keyDown(Keys.CONTROL);
        for (int i = from; i < to; i++) {
            WebElement item = options.get(i);
            if (!item.isSelected()) {
                builder.moveToElement(item).click(item);
            }
        }
        builder.keyUp(Keys.CONTROL);
        Action multiple = builder.build();
        multiple.perform();
    }
}

From source file:com.epam.jdi.uitests.mobile.appium.elements.base.Element.java

License:Open Source License

public void clickWithKeys(Keys... keys) {
    invoker.doJAction("Ctrl click on Element", () -> {
        Actions action = new Actions(getDriver());
        for (Keys key : keys)
            action = action.keyDown(key);
        action = action.moveToElement(getWebElement()).click();
        for (Keys key : keys)
            action = action.keyUp(key);
        action.perform();/*from   w  w w  .  j a  va 2 s. c  o  m*/
    });
}

From source file:com.epam.jdi.uitests.web.selenium.elements.base.Element.java

License:Open Source License

public void clickWithKeys(Keys... keys) {
    invoker.doJAction("Ctrl click on Element", () -> {
        Actions action = new Actions(getDriver());
        for (Keys key : keys) {
            action = action.keyDown(key);
        }/*w  ww. j a  v a 2  s  . c o m*/
        action = action.moveToElement(getWebElement()).click();
        for (Keys key : keys) {
            action = action.keyUp(key);
        }
        action.perform();
    });
}

From source file:com.ggasoftware.jdi_ui_tests.elements.base.Element.java

License:Open Source License

public void clickWithKeys(Keys... keys) {
    doJAction("Ctrl click on element", () -> {
        Actions action = new Actions(getDriver());
        for (Keys key : keys)
            action = action.keyDown(key);
        action = action.moveToElement(getWebElement()).click();
        for (Keys key : keys)
            action = action.keyUp(key);
        action.perform();// ww  w  .  j  av  a2  s.co m
    });
}

From source file:com.liferay.faces.portal.test.showcase.inputrichtext.InputRichTextTester.java

License:Open Source License

protected static void selectTextAndSendKeys(BrowserDriver browserDriver, String completeText,
        String textToSelect, CharSequence... keys) {

    if (!completeText.contains(textToSelect)) {
        throw new IllegalArgumentException(
                "\"" + completeText + "\" does not contain \"" + textToSelect + "\"");
    }/*  w  w  w  .j a v a  2 s  .co m*/

    Actions boldAndItalicize = browserDriver.createActions(BODY_XPATH);
    WebElement body = browserDriver.findElementByXpath(BODY_XPATH);
    boldAndItalicize.click(body);

    for (int i = 0; i < completeText.length(); i++) {
        boldAndItalicize.sendKeys(Keys.LEFT);
    }

    int beginIndex = completeText.indexOf(textToSelect);

    for (int i = 0; i < beginIndex; i++) {
        boldAndItalicize.sendKeys(Keys.RIGHT);
    }

    boldAndItalicize.keyDown(Keys.SHIFT);

    for (int i = 0; i < textToSelect.length(); i++) {
        boldAndItalicize.sendKeys(Keys.RIGHT);
    }

    boldAndItalicize.keyUp(Keys.SHIFT);
    boldAndItalicize.perform();
    browserDriver.sendKeysToElement(BODY_XPATH, keys);
}

From source file:com.me.jvmi.SelectElement.java

public void selectAll(Set<String> optionsText) {
    Actions shiftClick = new Actions(driver);
    shiftClick = shiftClick.keyDown(Keys.SHIFT);
    List<WebElement> options = select.findElements(By.tagName("option"));
    for (WebElement option : options) {
        if (optionsText.contains(option.getText())) {
            shiftClick = shiftClick.click(option);
        }//from  w w  w.  ja va  2 s  .  c om
    }
    shiftClick.keyUp(Keys.SHIFT).perform();
}

From source file:com.mkl.websuites.internal.command.impl.key.PressCommand.java

License:Apache License

@Override
protected void runStandardCommand() {
    Actions action = new Actions(browser);
    String[] keyTokens = keyCombination.trim().toUpperCase(Locale.getDefault()).split("-");
    for (String key : keyTokens) {
        if (isModifier(key)) {
            action = action.keyUp(keyFromModifier(key));
        } else {//from w  w  w  .  ja  va2s  .c om
            action = action.sendKeys(keyFromString(key));
        }
    }
    action.build().perform();
}

From source file:com.pentaho.gui.web.puc.BrowseFiles.java

License:Apache License

/**
 * This method will empty a folder in the repository given the full path to it, including the folder name
 *
 * Ex. "/public/plugin-samples/pentaho-cdf-dd" the SelectFolder method will be called with the path provided, it it
 * returns false an info will be shown on the logs saying the file wasn't deleted for it wasn't found. If it returns
 * true, all files shown on the files table will be selected, Delete button will be clicked on File Actions, it will
 * wait for popup and confirm the delete action.
 *
 * @param path//from   w  ww. j a v  a  2 s  .co  m
 */
public void EmptyFolder(String path) {
    if (SelectFolder(path)) {
        WebElement listFiles = this.elemHelper.WaitForElementPresenceAndVisible(this.DRIVER,
                By.xpath("//div[@id='fileBrowserFiles']/div[2]"));
        List<WebElement> AllFolderFiles = listFiles.findElements(By.xpath("//div[@class='title']"));

        // Check if the widget named exist
        if (AllFolderFiles != null) {
            if (AllFolderFiles.size() > 0) {
                WebElement[] arrayAllFolderFiles = new WebElement[AllFolderFiles.size()];
                AllFolderFiles.toArray(arrayAllFolderFiles);

                // Where we want to select three files
                // <the widget>
                // <the widget>.cdfde
                // <the widget>.component.xml
                // To do that we select each file (using the CONTROL key) and delete them.
                Actions action = new Actions(this.DRIVER);
                action.keyDown(Keys.CONTROL);
                for (WebElement arrayAllFolderFile : arrayAllFolderFiles) {
                    action.click(arrayAllFolderFile);
                }
                action.keyUp(Keys.CONTROL);
                action.build().perform();

                // Here we still in the iframe
                assertNotNull(this.elemHelper.WaitForElementVisibility(this.DRIVER, By.id("deleteButton")));
                this.elemHelper.WaitForElementPresenceAndVisible(this.DRIVER, By.id("deleteButton")).click();
                // Go back to root html
                this.DRIVER.switchTo().defaultContent();
                assertEquals(this.elemHelper
                        .WaitForElementPresenceAndVisible(this.DRIVER, By.cssSelector("div.gwt-HTML"))
                        .getText(), "Are you sure you want to move all selected items to the trash?");
                this.elemHelper.WaitForElementPresenceAndVisible(this.DRIVER, By.id("okButton")).click();

                // wait for visibility of waiting pop-up
                this.elemHelper.WaitForElementInvisibility(this.DRIVER,
                        By.xpath("//div[@class='busy-indicator-container waitPopup']"));

                this.elemHelper.WaitForElementInvisibility(this.DRIVER,
                        By.xpath("//div[@class='spinner large-spinner']"));
                this.elemHelper.WaitForElementInvisibility(this.DRIVER,
                        By.xpath("(//div[@class='spinner large-spinner'])[2]"));

            }
        }
    } else {
        LOG.info("folder not emptied for it was not found");
    }
}