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

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

Introduction

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

Prototype

public Actions click(WebElement target) 

Source Link

Document

Clicks in the middle of the given element.

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.ja v a  2 s  .c om*/
    }
    builder.click(element);
    for (Keys key : keys) {
        builder.keyUp(key);
    }

    Action action = builder.build();

    action.perform();
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

@Override
public void clickByAction(String locator) {
    Actions action = new Actions(webDriver);
    action.click(findClickableElement(locator));
}

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

License:Open Source License

public void clickCenter() {
    invoker.doJAction("Click in Center of Element", () -> {
        Actions builder = new Actions(getDriver());
        builder.click(getWebElement()).perform();
    });/*from   www  . ja v a 2 s .  c o  m*/
}

From source file:com.example.selenium.action.TableRowSelection.java

@Test
public void testRowSelectionUsingControlKey() throws InterruptedException {

    List<WebElement> tableRows = driver.findElements(By.xpath("//table[@id='dataTables-example']/tbody/tr"));

    //Select second and fourth row from table using Control Key.
    //Row Index start at 0
    Actions builder = new Actions(driver);
    builder.click(tableRows.get(0)).keyDown(Keys.CONTROL).click(tableRows.get(2)).keyUp(Keys.CONTROL).build()
            .perform();//  w  w  w.j  a  v  a  2 s .  c  o  m
    Thread.sleep(3000);

}

From source file:com.gargoylesoftware.htmlunit.html.HtmlSelect2Test.java

License:Apache License

/**
 * @exception Exception If the test fails
 *//*from   w  w  w .jav a 2 s  .  c om*/
@Test
@BuggyWebDriver({ FF, IE })
public void select() throws Exception {
    final String html = "<html><head><title>foo</title></head><body>\n"
            + "<form id='form1'><select name='select1' multiple>\n"
            + "  <option value='option1'>Option1</option>\n" + "  <option value='option2'>Option2</option>\n"
            + "  <option value='option3' selected='selected'>Option3</option>\n"
            + "  <option value='option4'>Option4</option>\n" + "</select>\n"
            + "<input type='submit' name='button' value='foo'/>\n" + "</form></body></html>";

    final WebDriver driver = loadPage2(html);

    final List<WebElement> options = driver.findElements(By.tagName("option"));

    final Actions actions = new Actions(driver);
    final Action selectThreeOptions = actions.click(options.get(1)).click(options.get(2)).click(options.get(3))
            .build();

    selectThreeOptions.perform();

    assertFalse(options.get(0).isSelected());
    assertFalse(options.get(1).isSelected());
    assertFalse(options.get(2).isSelected());
    assertTrue(options.get(3).isSelected());
}

From source file:com.gargoylesoftware.htmlunit.html.HtmlSelect2Test.java

License:Apache License

/**
 * @exception Exception If the test fails
 *//*from  www  . j  a va  2 s  .com*/
@Test
@BuggyWebDriver(IE)
public void shiftClick() throws Exception {
    final String html = "<html><head><title>foo</title></head><body>\n"
            + "<form id='form1'><select name='select1' multiple>\n"
            + "  <option value='option1'>Option1</option>\n" + "  <option value='option2'>Option2</option>\n"
            + "  <option value='option3' selected='selected'>Option3</option>\n"
            + "  <option value='option4'>Option4</option>\n" + "</select>\n"
            + "<input type='submit' name='button' value='foo'/>\n" + "</form></body></html>";

    final WebDriver driver = loadPage2(html);

    final List<WebElement> options = driver.findElements(By.tagName("option"));

    final Actions actions = new Actions(driver);
    final Action selectThreeOptions = actions.click(options.get(1)).keyDown(Keys.SHIFT).click(options.get(3))
            .keyUp(Keys.SHIFT).build();

    selectThreeOptions.perform();

    assertFalse(options.get(0).isSelected());
    assertTrue(options.get(1).isSelected());
    assertTrue(options.get(2).isSelected());
    assertTrue(options.get(3).isSelected());
}

From source file:com.gargoylesoftware.htmlunit.html.HtmlSelect2Test.java

License:Apache License

/**
 * @exception Exception If the test fails
 *//*from ww w .  j  a va 2s .co  m*/
@Test
@BuggyWebDriver({ FF, IE })
public void controlClick() throws Exception {
    final String html = "<html><head><title>foo</title></head><body>\n"
            + "<form id='form1'><select name='select1' multiple>\n"
            + "  <option value='option1'>Option1</option>\n" + "  <option value='option2'>Option2</option>\n"
            + "  <option value='option3' selected='selected'>Option3</option>\n"
            + "  <option value='option4'>Option4</option>\n" + "</select>\n"
            + "<input type='submit' name='button' value='foo'/>\n" + "</form></body></html>";

    final WebDriver driver = loadPage2(html);

    final List<WebElement> options = driver.findElements(By.tagName("option"));

    final Actions actions = new Actions(driver);
    final Action selectThreeOptions = actions.click(options.get(1)).keyDown(Keys.CONTROL).click(options.get(3))
            .keyUp(Keys.CONTROL).build();

    selectThreeOptions.perform();

    assertFalse(options.get(0).isSelected());
    assertTrue(options.get(1).isSelected());
    assertFalse(options.get(2).isSelected());
    assertTrue(options.get(3).isSelected());
}

From source file:com.ggasoftware.jdiuitest.web.selenium.elements.base.Element.java

License:Open Source License

public void clickCenter() {
    invoker.doJAction("Click in Center of Element", () -> {
        getWebElement().getSize(); //for scroll to object
        Actions builder = new Actions(getDriver());
        builder.click(getWebElement()).perform();
    });// w  w w  .j  a va  2 s.  c  o m
}

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

License:Open Source License

public void clickCenter() {
    doJAction("Click in Center of element", () -> {
        getWebElement().getSize(); //for scroll to object
        Actions builder = new Actions(getDriver());
        builder.click(getWebElement()).perform();
    });//from   ww w .  j  a va 2 s .  co  m
}

From source file:com.ggasoftware.uitest.control.Element.java

License:Open Source License

/**
 * Clicks in the middle of the given element. Equivalent to:
 * Actions.moveToElement(onElement).click()
 *
 * @return Parent instance//from   w w  w.  j ava 2 s  . c  o m
 */
public ParentPanel clickAction() {
    getWebElement().getSize(); //for scroll to object
    logAction(this, getParentClassName(), "clickAction");
    alwaysDoneAction(() -> {
        Actions builder = new Actions(getDriver());
        builder.click(getWebElement()).perform();
    });
    return parent;
}