Example usage for org.openqa.selenium WebElement click

List of usage examples for org.openqa.selenium WebElement click

Introduction

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

Prototype

void click();

Source Link

Document

Click this element.

Usage

From source file:com.dukescript.api.selenium.ExternalWebViewTest.java

License:Open Source License

@Test
public void withModelAndExistingWebView() throws InterruptedException {
    WebElement element = driver.findElement(By.id("target"));
    Assert.assertEquals("Hello", element.getText());
    WebElement button = driver.findElement(By.id("button"));
    button.click();
    Assert.assertEquals("World", element.getText());
    WebElement input = driver.findElement(By.id("input"));
    input.clear();/*www.j  a  v  a 2s  .  c om*/
    input.sendKeys("DukeScript");
    button.click();
    Assert.assertEquals("DukeScript", element.getText());
    WebElement findElement = driver.findElement(By.cssSelector(".bla"));
    Assert.assertNotNull(findElement);
    Assert.assertEquals("DukeScript", findElement.getText());
    List<WebElement> findElements = driver.findElements(By.cssSelector(".bla"));
    Assert.assertEquals(1, findElements.size());
}

From source file:com.dukescript.api.selenium.FindsByTest.java

License:Open Source License

@Test
public void withModel() {
    // please note that this method is not executed in BrwsrCtx
    // to allow seeing updates in the Browser while debugging a test
    WebElement element = driver.findElement(By.id("target"));
    Assert.assertEquals("Hello", element.getText());
    WebElement button = driver.findElement(By.id("button"));
    button.click();
    Assert.assertEquals("World", element.getText());
    WebElement input = driver.findElement(By.id("input"));
    input.clear();//w w w .  j  av  a2 s.c o  m
    input.sendKeys("DukeScript");
    button.click();
    Assert.assertEquals("DukeScript", element.getText());
    WebElement findElement = driver.findElement(By.cssSelector(".bla"));
    Assert.assertNotNull(findElement);
    Assert.assertEquals("DukeScript", findElement.getText());
}

From source file:com.easytox.automation.steps.addPhysicians.AddPhysiciansQuestSteps.java

@When("^Click on the Phisician icon on the LabClient list page for Quest lab$")
public void click_on_the_Phisician_icon_on_the_LabClient_list_page_for_Quest_lab() throws Throwable {
    Thread.sleep(2000);/* w w  w  .j  a va  2 s .c o  m*/

    WebElement table = driver.findElement(By.id("example"));

    List<WebElement> allRows = table.findElements(By.tagName("tr"));
    loop: {
        for (WebElement row : allRows) {
            List<WebElement> cells = row.findElements(By.xpath("./*"));
            for (WebElement cell : cells) {
                String cellText = cell.getText();
                if (cellText.equals(LAB_CLIENT)) {
                    WebElement icon = row.findElement(By.cssSelector(".fa.fa-user-md.fa-2x"));
                    icon.click();
                    break loop;
                }
            }
        }
    }
    Thread.sleep(2000);
}

From source file:com.easytox.automation.steps.addPhysicians.AddPhysiciansWestSteps.java

@When("^Click on the Phisician icon on the LabClient list page for West lab$")
public void click_on_the_Phisician_icon_on_the_LabClient_list_page_for_West_lab() throws Throwable {
    Thread.sleep(2000);/*from   ww  w .  jav a2 s  . co m*/

    WebElement table = driver.findElement(By.id("example"));

    List<WebElement> allRows = table.findElements(By.tagName("tr"));
    loop: {
        for (WebElement row : allRows) {
            List<WebElement> cells = row.findElements(By.xpath("./*"));
            for (WebElement cell : cells) {
                String cellText = cell.getText();
                if (cellText.equals(LAB_CLIENT)) {
                    WebElement icon = row.findElement(By.cssSelector(".fa.fa-user-md.fa-2x"));
                    icon.click();
                    break loop;
                }
            }
        }
    }
    Thread.sleep(2000);
}

From source file:com.easytox.automation.steps.addPhysicians.AddPhysiciansWestSteps.java

@When("^Select 'Edit' icon next to 'Angelina' physician$")
public void select_Edit_icon_next_to_Angelina_physician() throws Throwable {
    Thread.sleep(2000);/*from   w  w  w  . j  ava2s .com*/

    WebElement table = driver.findElement(By.id("example"));
    List<WebElement> allRows = table.findElements(By.tagName("tr"));
    loop: {
        for (WebElement row : allRows) {
            List<WebElement> cells = row.findElements(By.xpath("./*"));
            for (WebElement cell : cells) {
                String cellText = cell.getText();
                if (cellText.equals("Angelia")) {
                    WebElement icon = row.findElement(By.cssSelector(".fa.fa-pencil-square-o.fa-2x"));
                    icon.click();
                    break loop;
                }
            }
        }
    }
    Thread.sleep(2000);
}

From source file:com.easytox.automation.steps.addPhysicians.AddPhysiciansWestSteps.java

@When("^Click on the Phisician icon on the LabClient list page for Zest lab$")
public void click_on_the_Phisician_icon_on_the_LabClient_list_page_for_Zest_lab() throws Throwable {
    Thread.sleep(2000);//from   w w  w. j av a  2s. c  om

    WebElement table = driver.findElement(By.id("example"));

    List<WebElement> allRows = table.findElements(By.tagName("tr"));
    loop: {
        for (WebElement row : allRows) {
            List<WebElement> cells = row.findElements(By.xpath("./*"));
            for (WebElement cell : cells) {
                String cellText = cell.getText();
                if (cellText.equals(LAB_CLIENT)) {
                    WebElement icon = row.findElement(By.cssSelector(".fa.fa-user-md.fa-2x"));
                    icon.click();
                    break loop;
                }
            }
        }
    }
    Thread.sleep(2000);
}

From source file:com.easytox.automation.steps.addPhysicians.AddPhysiciansWestSteps.java

@When("^Select 'Edit' icon next to 'BradLemon' physician$")
public void select_Edit_icon_next_to_BradLemon_physician() throws Throwable {
    Thread.sleep(2000);//w  ww. ja  v a  2  s  . co  m

    WebElement table = driver.findElement(By.id("example"));
    List<WebElement> allRows = table.findElements(By.tagName("tr"));
    loop: {
        for (WebElement row : allRows) {
            List<WebElement> cells = row.findElements(By.xpath("./*"));
            for (WebElement cell : cells) {
                String cellText = cell.getText();
                if (cellText.equals("BradLemon")) {
                    WebElement icon = row.findElement(By.cssSelector(".fa.fa-pencil-square-o.fa-2x"));
                    icon.click();
                    break loop;
                }
            }
        }
    }
    Thread.sleep(2000);
}

From source file:com.easytox.automation.steps.LabClientImpl.java

private void checkAndClick(WebElement element) {
    if (element != null) {
        element.click();
    } else {// ww  w  . j ava  2  s. co  m
        Assert.fail("element is null!");
    }
}

From source file:com.ecfeed.core.runner.java.SeleniumTestMethodInvoker.java

License:Open Source License

private boolean processCheckBox(String elementType, MethodParameterNode methodParameterNode, String argument) {

    if (!NodePropertyDefElemType.isCheckbox(elementType)) {
        return false;
    }//  w  w  w.j ava 2s  .  co  m

    WebElement webElement = findWebElement(methodParameterNode);

    if (!isElementOkForInput(webElement)) {
        reportExceptionUnavailableElement(methodParameterNode);
    }
    String type = webElement.getAttribute(ATTR_TYPE);

    if (!StringHelper.isEqual(type, TYPE_CHECKBOX)) {
        return false;
    }

    boolean isAction = BooleanHelper.parseBoolean(argument);

    if (isAction) {
        webElement.click();
    }
    return true;
}

From source file:com.ecfeed.core.runner.java.SeleniumTestMethodInvoker.java

License:Open Source License

private boolean clickRadioButton(WebElement option, String argument) {

    String type = option.getAttribute(ATTR_TYPE);
    if (!StringHelper.isEqual(type, TYPE_RADIO)) {
        return false;
    }//from w w w.java2s.c  om

    String value = option.getAttribute(ATTR_VALUE);
    if (!StringHelper.isEqual(value, argument)) {
        return false;
    }

    option.click();
    return true;
}