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

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

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

import com.google.common.base.Throwables;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.InvocationTargetException;

public class UiObjectFactory {

    private static Logger LOG = LoggerFactory.getLogger(UiObjectFactory.class);

    public static UiObject from(By by) {
        UiObject result = new UiObject(by);
        result.getWrappedElement();
        return result;
    }


    public static  T decorate(UiObject uiObject, Class klass) {
        try {
            return klass.getConstructor(WebElement.class).newInstance(uiObject);
        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
                | NoSuchMethodException | SecurityException e) {
            LOG.error("Cannot decorate {} with class {}", uiObject, klass);
            Throwables.propagate(e);
        }
        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy