Example usage for org.openqa.selenium By className

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

Introduction

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

Prototype

public static By className(String className) 

Source Link

Document

Find elements based on the value of the "class" attribute.

Usage

From source file:com.epam.jdi.uitests.web.selenium.elements.pageobjects.annotations.WebAnnotationsUtil.java

License:Open Source License

public static By findByToBy(JFindBy locator) {
    if (locator == null)
        return null;

    if (!"".equals(locator.xpath()))
        return By.xpath(locator.xpath());
    if (!"".equals(locator.css()))
        return By.cssSelector(locator.css());
    if (!"".equals(locator.linkText()))
        return By.linkText(locator.linkText());
    if (!"".equals(locator.partialLinkText()))
        return By.partialLinkText(locator.partialLinkText());
    if (!"".equals(locator.tagName()))
        return By.tagName(locator.tagName());

    if (!"".equals(locator.text()))
        return By.xpath(".//*/text()[normalize-space(.) = " + Quotes.escape(locator.text()) + "]/parent::*");

    if (!"".equals(locator.attribute().name()))
        return getAttribute(locator.attribute().name(), locator.attribute().value());
    if (!"".equals(locator.id()))
        return By.id(locator.id());
    if (!"".equals(locator.className()))
        return By.className(locator.className());
    if (!"".equals(locator.name()))
        return By.name(locator.name());
    if (!"".equals(locator.value()))
        return getAttribute("value", locator.value());
    if (!"".equals(locator.title()))
        return getAttribute("title", locator.title());
    if (!"".equals(locator.type()))
        return getAttribute("type", locator.title());
    if (!"".equals(locator.model()))
        return getAttribute("ng-model", locator.model());
    if (!"".equals(locator.binding()))
        return getAttribute("ng-binding", locator.binding());
    if (!"".equals(locator.repeat()))
        return getAttribute("ng-repeat", locator.repeat());
    return null;//from   ww w  .j ava 2 s  .  c  o m
}

From source file:com.evolveum.midpoint.schrodinger.component.common.Paging.java

License:Apache License

public Paging<T> pageSize(int size) {
    Validate.isTrue(size > 0, "Size must be larger than zero.");

    SelenideElement parent = getParentElement();

    SelenideElement button = parent.$(By.cssSelector(".btn.btn-default.dropdown-toggle"));
    button.click();//  w ww . j av a2s .co m

    button.parent().$(By.className("dropdown-menu")).$$x(".//a").first().click();

    SelenideElement popover = parent.$$(By.className("popover-title")).findBy(Condition.text("Page size"))
            .parent(); //todo fix localization

    popover.$(By.tagName("input")).setValue(Integer.toString(size));
    popover.$(By.tagName("button")).click();

    return this;
}

From source file:com.evolveum.midpoint.schrodinger.component.common.PrismForm.java

License:Apache License

public PrismForm<T> addAttributeValue(String name, String value) {
    SelenideElement property = findProperty(name);

    $(By.className("prism-properties")).waitUntil(Condition.appears, MidPoint.TIMEOUT_MEDIUM_6_S);

    ElementsCollection values = property.$$(By.className("prism-property-value"));
    if (values.size() == 1) {
        values.first().$(By.className("form-control")).setValue(value);
    }/*from   w  ww. j  a v  a 2s . c o m*/

    // todo implement
    return this;
}

From source file:com.evolveum.midpoint.schrodinger.component.common.PrismForm.java

License:Apache License

public PrismForm<T> changeAttributeValue(String name, String oldValue, String newValue) {
    SelenideElement property = findProperty(name);

    $(By.className("prism-properties")).waitUntil(Condition.appears, MidPoint.TIMEOUT_MEDIUM_6_S);

    ElementsCollection values = property.$$(By.className("prism-property-value"));
    if (values.size() == 1) {
        values.first().$(By.className("form-control")).setValue(newValue);
    }/*from  w w w  . j  a  v a 2  s .  c  o m*/

    // todo implement
    return this;
}

From source file:com.evolveum.midpoint.schrodinger.component.common.PrismForm.java

License:Apache License

public PrismForm<T> addAttributeValue(QName name, String value) {
    SelenideElement property = findProperty(name);

    ElementsCollection values = property.$$(By.className("prism-property-value"));
    if (values.size() == 1) {
        values.first().$(By.className("form-control")).setValue(value);
    }/* w w w .ja v a2s  . c o m*/
    // todo implement
    return this;
}

From source file:com.evolveum.midpoint.schrodinger.component.common.PrismForm.java

License:Apache License

public PrismForm<T> setPasswordFieldsValues(QName name, String value) {
    SelenideElement property = findProperty(name);

    ElementsCollection values = property.$$(By.className("prism-property-value"));
    if (values.size() > 0) {
        ElementsCollection passwordInputs = values.first().$$(By.tagName("input"));
        if (passwordInputs != null) {
            passwordInputs.forEach(inputElement -> inputElement.setValue(value));
        }/* ww  w  .  j  a  va2s .c  om*/
    }
    return this;
}

From source file:com.evolveum.midpoint.schrodinger.component.common.PrismForm.java

License:Apache License

public PrismForm<T> setDropDownAttributeValue(QName name, String value) {
    SelenideElement property = findProperty(name);

    ElementsCollection values = property.$$(By.className("prism-property-value"));
    if (values.size() > 0) {
        SelenideElement dropDown = values.first().$(By.tagName("select"));
        if (dropDown != null) {
            dropDown.selectOptionContainingText(value);
        }/*from   w  ww  . j a  v a 2  s  .co  m*/
    }
    return this;
}

From source file:com.evolveum.midpoint.schrodinger.component.common.table.Table.java

License:Apache License

public Paging<T> paging() {
    SelenideElement pagingElement = getParentElement().$(By.className("boxed-table-footer-paging"));

    return new Paging(this, pagingElement);
}

From source file:com.evolveum.midpoint.testing.schrodinger.labs.ImportResourceTest.java

License:Apache License

@Test(groups = { "lab_3_1" }, dependsOnMethods = { "test001ImportCsvResource" }, priority = 2)
public void test003showUsingWizard() {
    ResourceWizardPage resourceWizard = navigateToViewResourcePage().clickShowUsingWizard();

    //wizard should appear
    Assert.assertTrue(//from w ww  .j  a v  a2 s  .  c o m
            $(By.className("wizard")).waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S).exists());

    Assert.assertTrue($(Schrodinger.byDataId("readOnlyNote"))
            .waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S).exists());

    //Configuration tab
    resourceWizard.clickOnWizardTab("Configuration");
    Assert.assertTrue($(Schrodinger.byDataId("configuration"))
            .waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S).exists());

    //Schema tab
    resourceWizard.clickOnWizardTab("Schema");
    Assert.assertTrue($(Schrodinger.byElementValue("a", "Schema")).shouldBe(Condition.visible).exists());
    $(By.linkText(ACCOUNT_OBJECT_CLASS_LINK)).shouldBe(Condition.visible).click();
    //Attributes table visibility check
    Assert.assertTrue($(Schrodinger.byDataId("attributeTable")).shouldBe(Condition.visible).exists());

    //check resource attributes are present
    RESOURCE_ATTRIBUTES.forEach(attr -> Assert.assertTrue($(Schrodinger.byElementValue("div", attr))
            .waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT_2_S).exists()));

}

From source file:com.example.selenium.find.elements.FindElementsTest.java

@Test
public void findByClassName() {

    try {// w  w  w  .j a v  a 2s  . c o m
        WebElement element = selenium.findElement(By.className("panel-title"));
        Assert.assertNotNull(element);
    } catch (NoSuchElementException ex) {
        Logger.getLogger(FindElementsTest.class.getName()).log(Level.SEVERE, null, ex);
    }

}