All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.automationrockstars.design.gir.webdriver.WebdriverUtils Maven / Gradle / Ivy

The newest version!
/*
 * 
 */
package com.automationrockstars.design.gir.webdriver;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

public class WebdriverUtils {

    private static final Logger log = LoggerFactory.getLogger(WebdriverUtils.class);

    public static List getChildren(WebElement parent) {
        log.debug("Looking for children of {}", webElementToString(parent));
        List children = parent.findElements(By.xpath(".//*"));
        for (WebElement child : children) {
            log.debug("Found {} ", webElementToString(child));

        }
        return children;
    }

    public static String webElementToString(WebElement element) {
        StringBuilder result = new StringBuilder();
        try {
            result.append(element.getText()).append(" ");
            result.append(element.getTagName()).append(" ");
            result.append(element.toString());
        } catch (Throwable ignore) {
            log.info("Strange stuff", ignore);
        }
        return result.toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy