Examples of Actions


Examples of org.openqa.selenium.interactions.Actions

        /*
         * Selenium doesn't properly drag and drop items in IE8. It tries to
         * start dragging an element from a position above the element itself.
         */
        if (BrowserUtil.isIE8(getDesiredCapabilities())) {
            Actions action = new Actions(getDriver());
            action.moveToElement(element);
            action.moveByOffset(0, 1);
            action.clickAndHold();
            action.moveByOffset(xOffset, yOffset);
            action.release();
            action.build().perform();
        } else {
            Actions action = new Actions(getDriver());
            action.dragAndDropBy(element, xOffset, yOffset);
            action.build().perform();
        }
    }
View Full Code Here

Examples of org.openqa.selenium.interactions.Actions

    private void closePopup() {
        WebElement dateFieldButton = dateField.findElement(By
                .className("v-datefield-button"));
        // To work reliably with IE, need to click and hold instead of just
        // clicking the button.
        Actions actions = new Actions(driver);
        actions.clickAndHold(dateFieldButton).perform();
    }
View Full Code Here

Examples of org.openqa.selenium.interactions.Actions

    }

    private void openPopup() throws InterruptedException {
        Dimension size = getInput().getSize();
        new Actions(getDriver()).moveToElement(getInput(), 0, 0)
                .moveByOffset(size.getWidth() + 5, size.getHeight() / 2)
                .click();
        // This fails in Opera for some weird reason
        // getDriver().findElement(By.className("v-datefield-button")).click();
    }
View Full Code Here

Examples of org.openqa.selenium.interactions.Actions

     * @param string
     */
    private void menuSub(String string) {
        getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))
                .click();
        new Actions(getDriver()).moveByOffset(100, 0).build().perform();
    }
View Full Code Here

Examples of org.openqa.selenium.interactions.Actions

        List<WebElement> textFields = getDriver().findElements(
                By.tagName("input"));
        WebElement tf1 = textFields.get(0);
        WebElement tf2 = textFields.get(1);
        tf1.sendKeys(initialText);
        new Actions(getDriver()).moveToElement(tf2).click().build().perform();

        WebElement activeElement = getFocusedElement();
        Assert.assertEquals("input", activeElement.getTagName());
        Assert.assertEquals("", activeElement.getAttribute("value"));

        tf1.sendKeys(incrementalText);
        new Actions(getDriver())
                .moveToElement(
                        getDriver().findElement(By.className("v-button")))
                .click().build().perform();
        activeElement = getFocusedElement();
        Assert.assertEquals("Just a button", activeElement.getText());
View Full Code Here

Examples of org.openqa.selenium.interactions.Actions

        String firstText = "This is";
        String secondText = " default value";

        tf2.sendKeys(firstText);
        tf1.sendKeys(initialText);
        new Actions(getDriver()).moveToElement(tf2).click().build().perform();

        WebElement activeElement = getFocusedElement();
        Assert.assertEquals("input", activeElement.getTagName());
        Assert.assertEquals(firstText, activeElement.getAttribute("value"));

        new Actions(getDriver()).sendKeys(secondText).build().perform();
        DesiredCapabilities capabilities = getDesiredCapabilities();
        if (capabilities.equals(BrowserUtil.ie(8))
                || capabilities.equals(BrowserUtil.ie(9))) {
            // IE8 and IE9 insert cursor in the start of input instead of end.
            Assert.assertEquals(secondText + firstText,
View Full Code Here

Examples of org.openqa.selenium.interactions.Actions

    //There's no point fixing this test before #7309 is actually fixed.
    public void pageIsNotScrolled() throws IOException {
        openTestURL();

        new Actions(driver).sendKeys(Keys.PAGE_DOWN).perform();

        $(TableElement.class).first().getCell(2, 0).click();

        compareScreen("scrolledDown");
    }
View Full Code Here

Examples of org.openqa.selenium.interactions.Actions

    public void textAreaShiftEnterEventPropagation()
            throws InterruptedException {
        openTestURL();

        WebElement textArea = $(TextAreaElement.class).first();
        Actions builder = new Actions(driver);
        builder.click(textArea);
        builder.sendKeys(textArea, "first line asdf");
        builder.keyDown(Keys.SHIFT);
        builder.sendKeys(Keys.ENTER);
        builder.keyUp(Keys.SHIFT);
        builder.sendKeys(textArea, "second line jkl;");
        builder.perform();

        // Should have triggered shortcut
        Assert.assertEquals("1. Shift-Enter button pressed", getLogRow(0));
    }
View Full Code Here

Examples of org.openqa.selenium.interactions.Actions

    @Test
    public void textAreaCtrlEnterEventPropagation() throws InterruptedException {
        openTestURL();

        WebElement textArea = $(TextAreaElement.class).first();
        Actions builder = new Actions(driver);
        builder.click(textArea);
        builder.sendKeys(textArea, "first line asdf");
        builder.keyDown(Keys.CONTROL);
        builder.sendKeys(Keys.ENTER);
        builder.keyUp(Keys.CONTROL);
        builder.sendKeys(textArea, "second line jkl;");
        builder.perform();

        // Should have triggered shortcut
        Assert.assertEquals("1. Ctrl-Enter button pressed", getLogRow(0));
    }
View Full Code Here

Examples of org.openqa.selenium.interactions.Actions

        ((TestBenchElementCommands) element).click(8, 7);
        element.clear();
        element.sendKeys("New value");
        assertEquals("New value", element.getAttribute("value"));
        if (BrowserUtil.isPhantomJS(getDesiredCapabilities())) {
            new Actions(getDriver()).sendKeys(Keys.ENTER).perform();
            Thread.sleep(500);
        } else {
            element.sendKeys(Keys.RETURN);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.