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

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

Introduction

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

Prototype

public Actions(WebDriver driver) 

Source Link

Usage

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

License:Apache License

@Test
public void testShiftCapitals() {
    new Actions(driver).sendKeys("a").sendKeys(Keys.SHIFT + "bc").sendKeys("d").build().perform();
    assertEquals("aBCd", fieldOne.getAttribute("value"));
}

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

License:Apache License

@Test
public void testHoldControl() {
    // Control + A
    new Actions(driver).sendKeys("a" + Keys.CONTROL + "a" + Keys.CONTROL + "bc").build().perform();
    assertEquals("bc", 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:com.opera.core.systems.DriverKeysTest.java

License:Apache License

@Test
public void testCopyPaste() throws Exception {
    new Actions(driver).sendKeys("hello world").sendKeys(Keys.CONTROL + "a").sendKeys(Keys.CONTROL + "c")
            .sendKeys(fieldTwo, Keys.CONTROL + "v").build().perform();

    assertEquals("hello world", fieldTwo.getAttribute("value"));
}

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

License:Apache License

@Test
public void testCopyPasteLeftControl() throws Exception {
    new Actions(driver).sendKeys("hello world").sendKeys(Keys.LEFT_CONTROL + "a")
            .sendKeys(Keys.LEFT_CONTROL + "c").sendKeys(fieldTwo, Keys.LEFT_CONTROL + "v").build().perform();

    assertEquals("hello world", fieldTwo.getAttribute("value"));
}

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

License:Apache License

@Test
@Ignore//  w w w. j a v a 2  s .  c  o  m
public void testKeyEnter() {
    getFixture("javascript.html");

    // Focus textbox
    driver.findElementById("one").click();

    // submit form
    start();
    new Actions(driver).sendKeys(Keys.ENTER).build().perform();
    stop();

    // +"?" for submitted query string
    assertTrue(driver.getCurrentUrl().endsWith("test.html?"));
}

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

License:Apache License

@Test
public void testTyping() {
    String text = "Hello, world!";

    driver.executeScript("document.getElementById('one').focus()");
    new Actions(driver).sendKeys(text).perform();

    assertEquals(text, driver.findElementById("one").getAttribute("value"));
}

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

License:Apache License

@Test
public void testTypingKeyEvents() {
    driver.get(fixture("keys.html"));

    new Actions(driver).sendKeys("hi").perform();

    String log = driver.findElementById("log").getAttribute("value");
    assertTrue(log.contains("press, 104, h,"));
    assertTrue(log.contains("up, 73, I,"));
}

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

License:Apache License

@After
public void afterEach() {
    // Tests sometimes cause problems because a context menu is opened on Desktop, ensure that we
    // cancel the context menu if any.
    new Actions(driver).sendKeys(Keys.ESCAPE).perform();
}

From source file:com.oracle.amc.sqe.util.webui.WebUIPage.java

License:Open Source License

public void moveTo(By elementPath) {
    Actions action = new Actions(webDriver);
    WebElement element = findElement(elementPath);
    action.moveToElement(element).build().perform();
}