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.atlassian.webdriver.jira.page.LicenseDetailsPage.java

License:Open Source License

public Date getDatePurchased() {

    String datePurchased = licenseTable.findElement(By.cssSelector("tr:nth-child(2) td:nth-child(2) b"))
            .getText();//from  w w  w.j a va  2s .  c  o  m
    SimpleDateFormat format = new SimpleDateFormat("dd/MM/yy");

    Date date;
    try {
        date = format.parse(datePurchased);
    } catch (ParseException e) {
        throw new RuntimeException(e);
    }

    return date;
}

From source file:com.atlassian.webdriver.jira.page.LicenseDetailsPage.java

License:Open Source License

public String getLicenseDescription() {
    return licenseTable.findElement(By.cssSelector("tr:nth-child(3) td:nth-child(2) b")).getText();
}

From source file:com.atlassian.webdriver.jira.page.LicenseDetailsPage.java

License:Open Source License

public String getServerId() {
    return licenseTable.findElement(By.cssSelector("tr:nth-child(4) td:nth-child(2) b")).getText();
}

From source file:com.atlassian.webdriver.jira.page.LicenseDetailsPage.java

License:Open Source License

public String getSupportEntitlementNumber() {
    return licenseTable.findElement(By.cssSelector("tr:nth-child(5) td:nth-child(2) b")).getText();
}

From source file:com.atlassian.webdriver.jira.page.LicenseDetailsPage.java

License:Open Source License

public int getUserLimit() {
    return Integer
            .valueOf(licenseTable.findElement(By.cssSelector("tr:nth-child(6) td:nth-child(2) b")).getText());
}

From source file:com.atlassian.webdriver.jira.page.LicenseDetailsPage.java

License:Open Source License

public int getActiveUsers() {
    String userLimit = licenseTable.findElement(By.cssSelector("tr:nth-child(6) td:nth-child(2)")).getText();

    Pattern re = Pattern.compile("[(]([0-9]+) currently active[)]");
    Matcher m = re.matcher(userLimit);

    if (m.find()) {
        String activeUSers = m.group(1);
        return Integer.valueOf(activeUSers);
    }/*  w  w  w.  j  av  a 2 s  .c om*/

    return -1;
}

From source file:com.atomicleopard.webelemental.Element.java

License:Open Source License

public Element find(String selector) {
    return find(By.cssSelector(selector));
}

From source file:com.atomicleopard.webelemental.ElementTest.java

License:Open Source License

@Test
public void shouldFindUsingCssSelector() {
    WebElement child1 = webElement("div", null, Expressive.<String, String>map("id", "div"));
    WebElement child2 = webElement("p", null, Expressive.<String, String>map("id", "p"));

    when(element2.findElements(Mockito.any(By.class))).thenReturn(list(child1, child2));
    Element element = spy(new Element(element2));
    Element result = element.find(".selector");
    assertThat(result.get(0).id(), is("div"));
    assertThat(result.get(1).id(), is("p"));

    verify(element, times(1)).find(By.cssSelector(".selector"));
}

From source file:com.autocognite.appium.lib.base.AbstractAppiumUiDriver.java

License:Apache License

public By getFinderType(String identifier, String idValue) throws Exception {
    By findBy = null;//  ww w  .  ja  v a 2  s . c om
    MobileWebIdentifyBy idType = null;
    try {
        idType = MobileWebIdentifyBy.valueOf(identifier.toUpperCase());
    } catch (Throwable e) {
        throwUnsupportedIndentifierException(this.getName(), "getFinderType", identifier);
    }
    switch (identifier.toUpperCase()) {
    case "ID":
        findBy = By.id(idValue);
        break;
    case "NAME":
        findBy = By.name(idValue);
        break;
    case "CLASS":
        findBy = By.className(idValue);
        break;
    case "LINK_TEXT":
        findBy = By.linkText(idValue);
        break;
    case "PARTIAL_LINK_TEXT":
        findBy = By.partialLinkText(idValue);
        break;
    case "XPATH":
        findBy = By.xpath(idValue);
        break;
    case "CSS":
        findBy = By.cssSelector(idValue);
        break;
    case "TAG":
        findBy = By.tagName(idValue);
        break;
    }
    return findBy;
}

From source file:com.autocognite.selenium.lib.SeleniumWebUiDriver.java

License:Apache License

@SuppressWarnings("incomplete-switch")
public By getFinderType(String identifier, String idValue) throws Exception {
    By findBy = null;/*from   w  ww .ja v a2 s .  com*/
    WebIdentifyBy idType = null;
    try {
        idType = WebIdentifyBy.valueOf(identifier.toUpperCase());
    } catch (Throwable e) {
        throwUnsupportedIndentifierException(Configurator.getComponentName("WEBDRIVER_AUTOMATOR"),
                "getFinderType", identifier);
    }
    switch (idType) {
    case ID:
        findBy = By.id(idValue);
        break;
    case NAME:
        findBy = By.name(idValue);
        break;
    case CLASS:
        findBy = By.className(idValue);
        break;
    case LINK_TEXT:
        findBy = By.linkText(idValue);
        break;
    case PARTIAL_LINK_TEXT:
        findBy = By.partialLinkText(idValue);
        break;
    case XPATH:
        findBy = By.xpath(idValue);
        break;
    case CSS:
        findBy = By.cssSelector(idValue);
        break;
    case TAG:
        findBy = By.tagName(idValue);
        break;
    }
    return findBy;
}