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

web.WebPageObject Maven / Gradle / Ivy

There is a newer version: 1.3.12
Show newest version
package web;

import org.openqa.selenium.support.PageFactory;

import java.util.ArrayList;
import java.util.List;

import static web.WebDriverInitializer.webDriver;

/**
 * Created by Ismail on 5/27/2018.
 * This class allow user to use WebPageObject/PageFactory techniques with framework
 */
public class WebPageObject {

    static List childClass = new ArrayList<>();

    public WebPageObject() {
        childClass.add(this);
    }

    // Initialize WebElements for WebPageObject class
    public static void initElements() {
        for (Object child : childClass) {
            PageFactory.initElements(webDriver, child);
        }
    }

    // Remove all childClass objects
    public static void removeElements() {
        childClass.removeAll(childClass);
    }
}