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

com.epam.jdi.light.elements.init.UIFactory Maven / Gradle / Ivy

There is a newer version: 1.6.0
Show newest version
package com.epam.jdi.light.elements.init;

import com.epam.jdi.light.elements.base.UIElement;
import com.epam.jdi.light.elements.complex.Dropdown;
import com.epam.jdi.light.elements.complex.WebList;
import org.openqa.selenium.By;

/**
 * Created by Roman_Iovlev on 3/28/2018.
 */
public class UIFactory {
    public static UIElement element(String locator) {
        return element(getLocator(locator));
    }
    public static UIElement element(By byLocator) {
        UIElement el =  new UIElement();
        el.setLocator(byLocator);
        return el;
    }
    private static By getLocator(String locator) {
        return locator.charAt(1) == '/'
                ? By.xpath(locator)
                : By.cssSelector(locator);
    }
    public static UIElement $(String locator) {
        return element(locator);
    }
    public static UIElement $(By locator) {
        return element(locator);
    }
    public static UIElement $(By locator, Object parent) {
        return element(locator).setParent(parent);
    }

    public static WebList list(String locator) {
        return list(getLocator(locator));
    }
    public static WebList list(By byLocator) {
        WebList list =  new WebList();
        list.setLocator(byLocator);
        return list;
    }
    public static WebList $$(String locator) {
        return list(locator);
    }
    public static WebList $$(By locator) {
        return list(locator);
    }
    public static WebList $$(By locator, Object parent) {
        return list(locator).setParent(parent);
    }

    public static Dropdown dropdown(String locator) {
        Dropdown el =  new Dropdown();
        By byLocator = getLocator(locator);
        el.setLocator(byLocator);
        return el;
    }
    public static Dropdown $d(String locator) {
        return dropdown(locator);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy