Example usage for org.openqa.selenium By tagName

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

Introduction

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

Prototype

public static By tagName(String tagName) 

Source Link

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 w  w  w.  j a v a2  s .  c o  m
}

From source file:com.etouch.cisco.common.CiscoMainPage.java

public void ValidECU(TestParameters input) throws InterruptedException {
    final int MAX_WAIT = 50;
    String tempecu = "";
    try {/*  w ww. j a  v a 2 s.co  m*/
        //SignIn(input);
        jsx.executeScript("window.document.getElementById('newCalculation').click()");
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements.ServerCount_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE))
                        .enterText(input.getParamMap().get("servercount"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements.CPUCount_XPATH, ObjectValType.XPATH,
                MAX_WAIT, WaitCondition.VISIBLE)).enterText(input.getParamMap().get("cpucount"));

        // testing kanika - start
        WebElement table = webDriver.findElement(By.id(MainPageElements.TotalECU_ID));
        List<WebElement> allRows = table.findElements(By.tagName("tr"));
        for (WebElement row : allRows) {
            List<WebElement> cells = row.findElements(By.tagName("td"));
            for (WebElement colElement : cells) {
                tempecu = colElement.getText();
            }
        }
        totalECU = Float.parseFloat(tempecu);
        // testing kanika - end
        ((SelectBox) webPage.findObject(ObjectType.SelectBox, "selectCpu", ObjectValType.ID, MAX_WAIT,
                WaitCondition.VISIBLE)).selectDropDownList("E5-2650 v2");
        // jsx.executeScript("document.getElementById('calculate').click()");
        //////webPage.sleep(100);
    } catch (Exception e) {
        log.error(getErrMessage());
        System.err.println(getErrMessage());
    }
}

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. c om

    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> 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));
        }/*  w  w w . j av a2s. co  m*/
    }
    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);
        }/*  w  ww .j av  a2  s .  c  om*/
    }
    return this;
}

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

License:Apache License

@Test(groups = { "lab_3_1" }, dependsOnMethods = { "test001ImportCsvResource" }, priority = 1)
public void test002ViewResourceDetailsPage() {

    //click Edit configuration on the resource edit page
    navigateToViewResourcePage().clickEditResourceConfiguration();

    SelenideElement uniqueAttributeField = $(Schrodinger.byDataResourceKey(UNIQUE_ATTRIBUTE_RESOURCE_KEY))
            .waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S);

    // Unique attribute name should be login
    Assert.assertTrue(uniqueAttributeField.$(By.tagName("input"))
            .waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S).getValue()
            .equals(UNIQUE_ATTRIBUTE_NAME));

    SelenideElement passwordAttributeField = $(Schrodinger.byDataResourceKey(PASSWORD_ATTRIBUTE_RESOURCE_KEY))
            .waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S);

    // Password attribute name should be password
    Assert.assertTrue(passwordAttributeField.$(By.tagName("input"))
            .waitUntil(Condition.appear, MidPoint.TIMEOUT_DEFAULT_2_S).getValue()
            .equals(PASSWORD_ATTRIBUTE_NAME));

}

From source file:com.example.getstarted.basicactions.UserJourneyTestIT.java

License:Apache License

private void checkAddBookPage() throws Exception {
    List<WebElement> inputContainers = driver.findElements(By.cssSelector("form .form-group"));
    assertTrue("Should have more than 5 inputs", inputContainers.size() > 5);
    assertEquals("First input should be Title", "Title",
            inputContainers.get(0).findElement(By.tagName("label")).getText());
    assertEquals("Second input should be Author", "Author",
            inputContainers.get(1).findElement(By.tagName("label")).getText());
    assertEquals("Third input should be Date Published", "Date Published",
            inputContainers.get(2).findElement(By.tagName("label")).getText());
    assertEquals("Fourth input should be Description", "Description",
            inputContainers.get(3).findElement(By.tagName("label")).getText());

    // The rest should be hidden
    for (Iterator<WebElement> iter = inputContainers.listIterator(5); iter.hasNext();) {
        WebElement el = iter.next();//from w w w. j av a  2  s.com
        assertTrue(el.getAttribute("class").indexOf("hidden") >= 0);
    }
}

From source file:com.example.getstarted.basicactions.UserJourneyTestIT.java

License:Apache License

private void checkBookList(String title, String author, String datePublished, String description)
        throws Exception {
    List<WebElement> media = driver.findElements(By.cssSelector("div.media"));
    assertEquals(1, media.size());/*from w w w . ja v  a2  s.co  m*/

    WebElement book = media.get(0);

    assertEquals(title, book.findElement(By.tagName("h4")).getText());
    assertEquals(author, book.findElement(By.tagName("p")).getText());
}

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

@Test
public void findByTagName() {

    try {//from w  w  w . j  a v a2  s .c o m
        List<WebElement> elements = selenium.findElements(By.tagName("input"));
        Assert.assertEquals(elements.size(), 3);
    } catch (NoSuchElementException ex) {
        Logger.getLogger(FindElementsTest.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:com.example.web.CarControllerSeleniumTests.java

License:Apache License

@Test
public void findCarShouldReturnCar() {

    when(findCar.findCar("Honda")).thenReturn(Optional.of(new Car("Honda")));

    this.webDriver.get("/cars/Honda.html");
    assertThat(webDriver.findElement(By.tagName("h1")).getText()).isEqualTo("Car");
    assertThat(webDriver.findElement(By.tagName("p")).getText()).isEqualTo("Found Honda");
}