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.crawljax.plugins.testilizer.generated.photogallery_EXND.GeneratedTestCase9.java

public void checkState19_AllAssertions() {
    if (!(driver.findElement(By.cssSelector("BODY")).getText().matches(
            "^[\\s\\S]*Clears Category flowers of all its own \\(direct\\) photos, nothing will be removed[\\s\\S]*$"))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;/*from w  ww  .jav  a2  s  .  c  om*/
    } // original assertion

    element = new DOMElement("DIV", "[Dismiss]",
            new ArrayList<String>(Arrays.asList("class=\"fieldCont\"", "style=\"margin-bottom: -1px;\"")));
    parentElement = new DOMElement("TD", "", new ArrayList<String>(
            Arrays.asList("colspan=\"2\"", "rowspan=\"2\"", "style=\"background-color: #F9F9F9; \"")));
    childrenElements.clear();
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("FIELDSET", "[Dismiss]", 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;
    } // predicted region assertion

    element = new DOMElement("TABLE", "[Dismiss]",
            new ArrayList<String>(Arrays.asList("cellpadding=\"0\"", "cellspacing=\"0\"", "id=\"helpBox\"",
                    "ondblclick=\"HideHelp();\"", "onmouseup=\"DontHideHelp();\"")));
    parentElement = new DOMElement("DIV", "",
            new ArrayList<String>(Arrays.asList("class=\"Helping\"", "id=\"helpBoxContainer\"", "style=\"\"")));
    childrenElements.clear();
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    childrenElements.add(new DOMElement("TBODY", "[Dismiss]", new ArrayList<String>(Arrays.asList(""))));
    if (!(isElementRegionTagAttPresent(parentElement, element, childrenElements))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // predicted region assertion

    element = new DOMElement("SPAN", "MyPhotoGallery",
            new ArrayList<String>(Arrays.asList("class=\"topHeadAround\"")));
    parentElement = new DOMElement("SPAN", "", new ArrayList<String>(Arrays.asList("class=\"VeryTitle\"")));
    childrenElements.clear();
    childrenElements.add(new DOMElement("#text", "", new ArrayList<String>(Arrays.asList(""))));
    if (!(isElementRegionTagAttPresent(parentElement, element, childrenElements))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // predicted region assertion

    element = new DOMElement("SPAN", "", new ArrayList<String>(Arrays.asList("style=\"padding-left: 20px;\"")));
    parentElement = new DOMElement("FORM", "",
            new ArrayList<String>(Arrays.asList("action=\"?page=categories&cid=1&cmd=del\"", "method=\"post\"",
                    "onsubmit=\"javascript:return confirmDelete('Default Category');\"")));
    childrenElements.clear();
    //      if(!(isElementRegionTagAttPresent(parentElement , element, childrenElements))){System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());  return;} // predicted region assertion

}

From source file:com.crawljax.plugins.testilizer.generated.photogallery_EXND.GeneratedTestCase9.java

public void checkState21_GeneratedAssertions() {
    if (!(isElementPresent(By.cssSelector("div#Granny[id=\"Granny\"]")))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;/*from  w  w w  . ja v a  2 s.co m*/
    } // generated assertion in case of ElementTagAttMatch

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

    element = new DOMElement("IMG", "", new ArrayList<String>(Arrays.asList("id=\"ss_photo\"",
            "onload=\"javscript:ss_loaddone();\"", "src=\"images/000006_rryky_0.jpg\"")));
    parentElement = new DOMElement("A", "", new ArrayList<String>(
            Arrays.asList("href=\".?p=6\"", "id=\"ss_link2\"", "style=\"display:inline;\"")));
    childrenElements.clear();
    if (!(isElementRegionTagPresent(parentElement, element, childrenElements))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of RegionTagMatch

    element = new DOMElement("SPAN", "1", new ArrayList<String>(Arrays.asList("id=\"ss_n\"")));
    parentElement = new DOMElement("DIV", "", new ArrayList<String>(Arrays.asList("class=\"titlepart\"",
            "style=\"letter-spacing: 2px; padding-bottom: 1em; margin-bottom: 0px;\"")));
    childrenElements.clear();
    childrenElements.add(new DOMElement("#text", "1", 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("SPAN", "2", new ArrayList<String>(Arrays.asList("id=\"ss_n\"")));
    parentElement = new DOMElement("DIV", "", new ArrayList<String>(Arrays.asList("class=\"titlepart\"",
            "style=\"letter-spacing: 2px; padding-bottom: 1em; margin-bottom: 0px;\"")));
    childrenElements.clear();
    childrenElements.add(new DOMElement("#text", "2", 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.photogallery_EXND.GeneratedTestCase9.java

public void checkState22_GeneratedAssertions() {
    if (!(isElementPresent(By.cssSelector("div#Granny[id=\"Granny\"]")))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;/*from w  w  w .  ja  va2s  .c o m*/
    } // generated assertion in case of ElementTagAttMatch

    element = new DOMElement("IMG", "", new ArrayList<String>(Arrays.asList("id=\"ss_photo\"",
            "onload=\"javscript:ss_loaddone();\"", "src=\"images/000006_rryky_0.jpg\"")));
    parentElement = new DOMElement("A", "", new ArrayList<String>(
            Arrays.asList("href=\".?p=6\"", "id=\"ss_link2\"", "style=\"display:inline;\"")));
    childrenElements.clear();
    if (!(isElementRegionTagPresent(parentElement, element, childrenElements))) {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        return;
    } // generated assertion in case of RegionTagMatch

    element = new DOMElement("SPAN", "1", new ArrayList<String>(Arrays.asList("id=\"ss_n\"")));
    parentElement = new DOMElement("DIV", "", new ArrayList<String>(Arrays.asList("class=\"titlepart\"",
            "style=\"letter-spacing: 2px; padding-bottom: 1em; margin-bottom: 0px;\"")));
    childrenElements.clear();
    childrenElements.add(new DOMElement("#text", "1", 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("SPAN", "2", new ArrayList<String>(Arrays.asList("id=\"ss_n\"")));
    parentElement = new DOMElement("DIV", "", new ArrayList<String>(Arrays.asList("class=\"titlepart\"",
            "style=\"letter-spacing: 2px; padding-bottom: 1em; margin-bottom: 0px;\"")));
    childrenElements.clear();
    childrenElements.add(new DOMElement("#text", "2", 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("SPAN", "Yourratingsaved!",
            new ArrayList<String>(Arrays.asList("id=\"rateStatus\"")));
    parentElement = new DOMElement("DIV", "", new ArrayList<String>(Arrays.asList("")));
    childrenElements.clear();
    childrenElements.add(new DOMElement("#text", "Yourratingsaved!", 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.daarons.transfer.DownloadTask.java

License:Apache License

private void enterPassword(String password) {
    WebElement passwordInput = driver.findElement(
            By.cssSelector("body > div > div > div.transfer > div > div.transfer__contents > div > input"));
    passwordInput.sendKeys(password);/*from  w w w  .  j a  va2 s.  c  o m*/
    WebElement enterPasswordBtn = driver.findElement(By.className("transfer__button"));
    enterPasswordBtn.click();
}

From source file:com.daarons.transfer.DownloadTask.java

License:Apache License

private String getFileName() {
    String fileName = null;//from   www  .  j  a v  a 2s . c o m
    try {
        WebElement fileNameElement = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
                "body > div > div > div.transfer > div > div.scrollable.transfer__contents > div.scrollable__content > ul > li > span.filelist__name")));
        fileName = fileNameElement.getText();
    } catch (Exception e) {
        log.error(e);
    }
    return fileName;
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private boolean logIn(String emailAddress, String password) {
    try {/*from ww w .  ja v  a 2s  . co  m*/
        WebElement emailInput = longWait.until(ExpectedConditions.presenceOfElementLocated(
                By.cssSelector("#signin__form > div > div > form > div:nth-child(1) > input")));
        emailInput.sendKeys(emailAddress);
        WebElement passwordInput = longWait.until(ExpectedConditions.presenceOfElementLocated(
                By.cssSelector("#signin__form > div > div > form > div:nth-child(2) > input")));
        passwordInput.sendKeys(password);
        WebElement logInButton = longWait.until(ExpectedConditions
                .presenceOfElementLocated(By.cssSelector("#signin__form > div > div > form > button")));
        logInButton.click();
        Thread.sleep(5000);
        return true;
    } catch (Exception ex) {
        log.error("Problem", ex);
        return false;
    }
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private void clickButtonToChooseEmailOrLink() {
    WebElement emailOrLinkButton = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.transfer__footer > svg")));
    emailOrLinkButton.click();/*from  w  w  w.j a va 2s .c o m*/
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private void clickEmailButton() {
    WebElement emailButton = smallWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer > div > div.scrollable.transfer__contents.scrollable--overflow-top > div.scrollable__content > div.transfer__options > div.transfer__option > div > svg > path")));
    String transform = getTransformAttribute(emailButton);
    if (!transform.equals("translate(0, 0)")) {
        emailButton.click();// w ww.  ja  v a 2 s  .com
    }
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private void inputMessage(Message message) {
    WebElement toInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__fields > div.uploader__autosuggest > input")));
    toInput.clear();//www . ja v  a  2  s .  co  m
    toInput.sendKeys(message.getTo());
    WebElement fromInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__fields > input")));
    fromInput.clear();
    fromInput.sendKeys(message.getFrom());
    WebElement messageInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__fields > div.uploader__message > textarea")));
    messageInput.clear();
    messageInput.sendKeys(message.getMessage());
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private void clickLinkButton() {
    WebElement linkButton = smallWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer > div > div.scrollable.transfer__contents.scrollable--overflow-top > div.scrollable__content > div.transfer__options > div.transfer__option > div > svg > path")));
    String transform = getTransformAttribute(linkButton);
    if (transform.equals("translate(0, 0)")) {
        linkButton.click();/*from  ww w .  j  av  a2 s.com*/
    }
}