Example usage for org.openqa.selenium By cssSelector

List of usage examples for org.openqa.selenium By cssSelector

Introduction

In this page you can find the example usage for org.openqa.selenium By cssSelector.

Prototype

public static By cssSelector(String cssSelector) 

Source Link

Document

Find elements via the driver's underlying W3C Selector engine.

Usage

From source file:com.continuuity.test.TestUtil.java

License:Apache License

public String getHTMLClasses(String cssSelector) {
    return globalDriver.findElement(By.cssSelector(cssSelector)).getAttribute("class");
}

From source file:com.continuuity.test.TestUtil.java

License:Apache License

public void genericDeleteTest(String expectedUrl) {
    WebElement deleteForm = globalDriver.findElement(By.cssSelector(".delete-form"));
    deleteForm.submit();/* w w w.  j a va2  s  .c  o m*/
    Global.driverWait(1);
    globalDriver.findElement(By.cssSelector(".action-submit-delete")).click();
    Global.driverWait(1);
    assertEquals(expectedUrl, globalDriver.getCurrentUrl());
}

From source file:com.conwet.silbops.EndToEndHTMLIT.java

License:Open Source License

@Test
public void shouldCloseConnection() {

    System.out.println("start close connection test...");
    shouldOpenConnection();//  www  .  j a v  a  2 s  .co m
    cleanTextArea("messageTextArea");

    System.out.println("selecting endpoints to close...");

    // iterates through options and close endPoints
    WebElement disconnect = browser.findElement(By.id("disconnectButton"));
    List<String> endpointList = new ArrayList<>();

    for (WebElement option : browser.findElements(By.cssSelector("option[id*=\"#\"]"))) {

        System.out.println("disconnecting " + option.getText());

        endpointList.add(option.getAttribute("id"));
        disconnect.click();
    }

    System.out.println("done.");

    System.out.print("waiting disconnect message...");
    waitMessage("messageTextArea", "disconnected");
    String msg = getTextAreaValue("messageTextArea");

    for (String endpoint : endpointList) {

        assertThat(msg).contains(endpoint);
    }

    System.out.println("done.");
    System.out.println("end close connection test");
}

From source file:com.crawljax.plugins.testilizer.generated.claroline_EXND.GeneratedTestCase11.java

@Test
public void method11() {
    driver.get(url);/*from  www.j a  va2s . co  m*/
    //From state 0 to state 1
    //Eventable{eventType=click, identification=cssSelector button[type="submit"], element=Element{node=[BUTTON: null], tag=BUTTON, text=Enter, attributes={tabindex=3, type=submit}}, source=StateVertexImpl{id=0, name=index}, target=StateVertexImpl{id=1, name=state1}}
    mutateDOMTree(0);
    checkState0_OriginalAssertions();
    checkState0_ReusedAssertions();
    checkState0_GeneratedAssertions();
    checkState0_LearnedAssertions();
    checkState0_AllAssertions();
    checkState0_RandAssertions1();
    checkState0_RandAssertions2();
    checkState0_RandAssertions3();
    checkState0_RandAssertions4();
    checkState0_RandAssertions5();
    driver.findElement(By.id("login")).clear();
    driver.findElement(By.id("login")).sendKeys("nainy");
    driver.findElement(By.id("password")).clear();
    driver.findElement(By.id("password")).sendKeys("nainy");
    driver.findElement(By.cssSelector("button[type=\"submit\"]")).click();
    //From state 1 to state 2
    //Eventable{eventType=click, identification=text Platform administration, element=Element{node=[A: null], tag=A, text=Platform administration, attributes={href=/claroline-1.11.7/claroline/admin/, target=_top}}, source=StateVertexImpl{id=1, name=state1}, target=StateVertexImpl{id=2, name=state2}}
    mutateDOMTree(1);
    checkState1_OriginalAssertions();
    checkState1_ReusedAssertions();
    checkState1_GeneratedAssertions();
    checkState1_LearnedAssertions();
    checkState1_AllAssertions();
    checkState1_RandAssertions1();
    checkState1_RandAssertions2();
    checkState1_RandAssertions3();
    checkState1_RandAssertions4();
    checkState1_RandAssertions5();
    driver.findElement(By.linkText("Platform administration")).click();
    //From state 2 to state 107
    //Eventable{eventType=click, identification=text Modules, element=Element{node=[A: null], tag=A, text=Modules, attributes={href=module/module_list.php}}, source=StateVertexImpl{id=2, name=state2}, target=StateVertexImpl{id=107, name=state107}}
    mutateDOMTree(2);
    checkState2_OriginalAssertions();
    checkState2_ReusedAssertions();
    checkState2_GeneratedAssertions();
    checkState2_LearnedAssertions();
    checkState2_AllAssertions();
    checkState2_RandAssertions1();
    checkState2_RandAssertions2();
    checkState2_RandAssertions3();
    checkState2_RandAssertions4();
    checkState2_RandAssertions5();
    driver.findElement(By.linkText("Modules")).click();
    //From state 107 to state 108
    //Eventable{eventType=click, identification=cssSelector .claroTable > tbody:nth-child(2) > tr:nth-child(11) > td:nth-child(6) > a:nth-child(1) > img:nth-child(1), element=Element{node=[IMG: null], tag=IMG, text=, attributes={alt=Properties, src=/claroline-1.11.7/web/img/settings.png?1232379976}}, source=StateVertexImpl{id=107, name=state107}, target=StateVertexImpl{id=108, name=state108}}
    mutateDOMTree(107);
    checkState107_OriginalAssertions();
    checkState107_ReusedAssertions();
    checkState107_GeneratedAssertions();
    checkState107_LearnedAssertions();
    checkState107_AllAssertions();
    checkState107_RandAssertions1();
    checkState107_RandAssertions2();
    checkState107_RandAssertions3();
    checkState107_RandAssertions4();
    checkState107_RandAssertions5();
    driver.findElement(By.cssSelector(
            ".claroTable > tbody:nth-child(2) > tr:nth-child(11) > td:nth-child(6) > a:nth-child(1) > img:nth-child(1)"))
            .click();
    //From state 108 to state 151
    //Eventable{eventType=click, identification=text Local settings, element=Element{node=[A: null], tag=A, text=Local settings, attributes={href=module.php?module_id=11&item=LOCAL}}, source=StateVertexImpl{id=108, name=state108}, target=StateVertexImpl{id=151, name=state151}}
    mutateDOMTree(108);
    checkState108_OriginalAssertions();
    checkState108_ReusedAssertions();
    checkState108_GeneratedAssertions();
    checkState108_LearnedAssertions();
    checkState108_AllAssertions();
    checkState108_RandAssertions1();
    checkState108_RandAssertions2();
    checkState108_RandAssertions3();
    checkState108_RandAssertions4();
    checkState108_RandAssertions5();
    driver.findElement(By.linkText("Local settings")).click();
    //From state 151 to state 156
    //Eventable{eventType=click, identification=cssSelector input[type="submit"], element=Element{node=[INPUT: null], tag=INPUT, text=, attributes={type=submit, value=Ok}}, source=StateVertexImpl{id=151, name=state151}, target=StateVertexImpl{id=156, name=state156}}
    mutateDOMTree(151);
    checkState151_OriginalAssertions();
    checkState151_ReusedAssertions();
    checkState151_GeneratedAssertions();
    checkState151_LearnedAssertions();
    checkState151_AllAssertions();
    checkState151_RandAssertions1();
    checkState151_RandAssertions2();
    checkState151_RandAssertions3();
    checkState151_RandAssertions4();
    checkState151_RandAssertions5();
    driver.findElement(By.cssSelector("input[type=\"submit\"]")).click();
    //From state 156 to state 160
    //Eventable{eventType=click, identification=text About, element=Element{node=[A: null], tag=A, text=About, attributes={href=module.php?module_id=11&item=About}}, source=StateVertexImpl{id=156, name=state156}, target=StateVertexImpl{id=160, name=state160}}
    mutateDOMTree(156);
    checkState156_OriginalAssertions();
    checkState156_ReusedAssertions();
    checkState156_GeneratedAssertions();
    checkState156_LearnedAssertions();
    checkState156_AllAssertions();
    checkState156_RandAssertions1();
    checkState156_RandAssertions2();
    checkState156_RandAssertions3();
    checkState156_RandAssertions4();
    checkState156_RandAssertions5();
    driver.findElement(By.linkText("About")).click();
    //From state 160 to state 87
    //Eventable{eventType=click, identification=text Logout, element=Element{node=[A: null], tag=A, text=Logout, attributes={href=/claroline-1.11.7/index.php?logout=true, target=_top}}, source=StateVertexImpl{id=160, name=state160}, target=StateVertexImpl{id=87, name=state87}}
    mutateDOMTree(160);
    checkState160_OriginalAssertions();
    checkState160_ReusedAssertions();
    checkState160_GeneratedAssertions();
    checkState160_LearnedAssertions();
    checkState160_AllAssertions();
    checkState160_RandAssertions1();
    checkState160_RandAssertions2();
    checkState160_RandAssertions3();
    checkState160_RandAssertions4();
    checkState160_RandAssertions5();
    driver.findElement(By.linkText("Logout")).click();
    //Sink node at state 87
    mutateDOMTree(87);
    checkState87_OriginalAssertions();
    checkState87_ReusedAssertions();
    checkState87_GeneratedAssertions();
    checkState87_LearnedAssertions();
    checkState87_AllAssertions();
    checkState87_RandAssertions1();
    checkState87_RandAssertions2();
    checkState87_RandAssertions3();
    checkState87_RandAssertions4();
    checkState87_RandAssertions5();
}

From source file:com.crawljax.plugins.testilizer.generated.claroline_EXND.GeneratedTestCase11.java

public void checkState1_GeneratedAssertions() {
    if (!(isElementPresent(By.cssSelector("div.toolTitleBlock[class=\"toolTitleBlock\"]")))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;//  w  ww . ja v a 2 s. com
    } // generated assertion in case of ElementTagAttMatch

    if (!(isElementPresent(By.id("claroBody")))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of ElementTagAttMatch

    element = new DOMElement("TABLE", "", new ArrayList<String>(Arrays.asList("border=\"0\"",
            "cellspacing=\"2\"", "class=\"claroTable emphaseLine\"", "width=\"100%\"")));
    parentElement = new DOMElement("DIV", "", new ArrayList<String>(Arrays.asList("id=\"claroBody\"")));
    childrenElements.clear();
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("THEAD", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("TBODY", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    if (!(isElementRegionTagPresent(parentElement, element, childrenElements))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of RegionTagMatch

    element = new DOMElement("TABLE", "", new ArrayList<String>(Arrays.asList("border=\"0\"",
            "cellspacing=\"2\"", "class=\"claroTable emphaseLine\"", "width=\"100%\"")));
    parentElement = new DOMElement("DIV", "", new ArrayList<String>(Arrays.asList("id=\"claroBody\"")));
    childrenElements.clear();
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements
            .add(new DOMElement("THEAD", "TitleVisibilityOrder", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("TBODY", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    if (!(isElementRegionTagPresent(parentElement, element, childrenElements))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of RegionTagMatch

}

From source file:com.crawljax.plugins.testilizer.generated.claroline_EXND.GeneratedTestCase11.java

public void checkState2_GeneratedAssertions() {
    if (!(isElementPresent(By.cssSelector("div.toolTitleBlock[class=\"toolTitleBlock\"]")))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;/* ww  w.j av  a 2s .  c o m*/
    } // generated assertion in case of ElementTagAttMatch

    if (!(isElementPresent(By.id("claroBody")))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of ElementTagAttMatch

    if (!(isElementPresent(
            By.cssSelector("div.claroDialogBox.boxWarning[class=\"claroDialogBox boxWarning\"]")))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of ElementTagAttMatch

}

From source file:com.crawljax.plugins.testilizer.generated.claroline_EXND.GeneratedTestCase11.java

public void checkState107_GeneratedAssertions() {
    element = new DOMElement("TABLE", "", new ArrayList<String>(Arrays.asList("border=\"0\"",
            "cellspacing=\"2\"", "class=\"claroTable emphaseLine\"", "width=\"100%\"")));
    parentElement = new DOMElement("DIV", "", new ArrayList<String>(Arrays.asList("id=\"claroBody\"")));
    childrenElements.clear();// w w  w.j a  va2s . c  o m
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("THEAD", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("TBODY", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    if (!(isElementRegionTagAttPresent(parentElement, element, childrenElements))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of RegionTagAttMatch

    element = new DOMElement("TABLE", "", new ArrayList<String>(Arrays.asList("border=\"0\"",
            "cellspacing=\"2\"", "class=\"claroTable emphaseLine\"", "width=\"100%\"")));
    parentElement = new DOMElement("DIV", "", new ArrayList<String>(Arrays.asList("id=\"claroBody\"")));
    childrenElements.clear();
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements
            .add(new DOMElement("THEAD", "TitleVisibilityOrder", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("TBODY", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    if (!(isElementRegionTagAttPresent(parentElement, element, childrenElements))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of RegionTagAttMatch

    if (!(isElementPresent(By.cssSelector("div.toolTitleBlock[class=\"toolTitleBlock\"]")))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of ElementTagAttMatch

    if (!(isElementPresent(By.id("claroBody")))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of ElementTagAttMatch

    if (!(isElementPresent(By.cssSelector(
            "TABLE.claroTable.emphaseLine[border=\"0\"][cellspacing=\"2\"][class=\"claroTable emphaseLine\"][width=\"100%\"]")))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of ElementTagAttMatch

}

From source file:com.crawljax.plugins.testilizer.generated.claroline_EXND.GeneratedTestCase11.java

public void checkState108_GeneratedAssertions() {
    if (!(isElementPresent(By.cssSelector("div.toolTitleBlock[class=\"toolTitleBlock\"]")))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;/*w  w  w  .  j  ava2 s. co  m*/
    } // generated assertion in case of ElementTagAttMatch

    if (!(isElementPresent(By.id("claroBody")))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of ElementTagAttMatch

}

From source file:com.crawljax.plugins.testilizer.generated.claroline_EXND.GeneratedTestCase11.java

public void checkState151_GeneratedAssertions() {
    if (!(isElementPresent(By.cssSelector("div.toolTitleBlock[class=\"toolTitleBlock\"]")))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;// w ww  .j av a2s  . c  om
    } // generated assertion in case of ElementTagAttMatch

    if (!(isElementPresent(By.id("claroBody")))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of ElementTagAttMatch

    element = new DOMElement("FORM", "",
            new ArrayList<String>(Arrays.asList(
                    "action=\"/claroline-1.11.7/claroline/admin/tool/config_edit.php?config_code=CLWRK\"",
                    "method=\"post\"", "name=\"editConfClass\"")));
    parentElement = new DOMElement("DIV", "", new ArrayList<String>(Arrays.asList("id=\"claroBody\"")));
    childrenElements.clear();
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(
            Arrays.asList("name=\"config_code\"", "type=\"hidden\"", "value=\"CLWRK\""))));
    childrenElements.add(new DOMElement("INPUT", "",
            new ArrayList<String>(Arrays.asList("name=\"section\"", "type=\"hidden\"", "value=\"main\""))));
    childrenElements.add(new DOMElement("#text", "",
            new ArrayList<String>(Arrays.asList("name=\"cmd\"", "type=\"hidden\"", "value=\"save\""))));
    childrenElements.add(new DOMElement("INPUT", "",
            new ArrayList<String>(Arrays.asList("border=\"0\"", "cellpadding=\"5\"", "width=\"100%\""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("INPUT", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("TABLE", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    if (!(isElementRegionTagPresent(parentElement, element, childrenElements))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of RegionTagMatch

    element = new DOMElement("FORM", "",
            new ArrayList<String>(Arrays.asList(
                    "action=\"/claroline-1.11.7/claroline/admin/tool/config_edit.php?config_code=CLWRK\"",
                    "method=\"post\"", "name=\"editConfClass\"")));
    parentElement = new DOMElement("DIV", "", new ArrayList<String>(Arrays.asList("id=\"claroBody\"")));
    childrenElements.clear();
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(
            Arrays.asList("name=\"config_code\"", "type=\"hidden\"", "value=\"CLWRK\""))));
    childrenElements.add(new DOMElement("INPUT", "",
            new ArrayList<String>(Arrays.asList("name=\"section\"", "type=\"hidden\"", "value=\"quota\""))));
    childrenElements.add(new DOMElement("#text", "",
            new ArrayList<String>(Arrays.asList("name=\"cmd\"", "type=\"hidden\"", "value=\"save\""))));
    childrenElements.add(new DOMElement("INPUT", "",
            new ArrayList<String>(Arrays.asList("border=\"0\"", "cellpadding=\"5\"", "width=\"100%\""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("INPUT", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("TABLE", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    if (!(isElementRegionTagPresent(parentElement, element, childrenElements))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of RegionTagMatch

    element = new DOMElement("FORM", "",
            new ArrayList<String>(Arrays.asList(
                    "action=\"/claroline-1.11.7/claroline/admin/tool/config_edit.php?config_code=CLQWZ\"",
                    "method=\"post\"", "name=\"editConfClass\"")));
    parentElement = new DOMElement("DIV", "", new ArrayList<String>(Arrays.asList("id=\"claroBody\"")));
    childrenElements.clear();
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(
            Arrays.asList("name=\"config_code\"", "type=\"hidden\"", "value=\"CLQWZ\""))));
    childrenElements.add(new DOMElement("INPUT", "",
            new ArrayList<String>(Arrays.asList("name=\"section\"", "type=\"hidden\"", "value=\"main\""))));
    childrenElements.add(new DOMElement("#text", "",
            new ArrayList<String>(Arrays.asList("name=\"cmd\"", "type=\"hidden\"", "value=\"save\""))));
    childrenElements.add(new DOMElement("INPUT", "",
            new ArrayList<String>(Arrays.asList("border=\"0\"", "cellpadding=\"5\"", "width=\"100%\""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("INPUT", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("TABLE", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    if (!(isElementRegionTagPresent(parentElement, element, childrenElements))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of RegionTagMatch

}

From source file:com.crawljax.plugins.testilizer.generated.claroline_EXND.GeneratedTestCase11.java

public void checkState156_OriginalAssertions() {
    if (!(driver.findElement(By.cssSelector("div.claroDialogBox.boxSuccess")).getText()
            .matches("^[\\s\\S]*Properties for Wiki, \\(CLWIKI\\) are now effective on server\\.[\\s\\S]*$"))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;/*from www  . j a va 2 s . co  m*/
    } // original assertion

}