package Support;

import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.PageFactory;

public abstract class BasicPage {

    final WebDriver driver;

    /**
     * constructor
     * @param driver which we are using
     */
    public BasicPage(WebDriver driver)
    {
        this.driver=driver;
        PageFactory.initElements(driver,this);
    }



    /**
     * check if element is present on page
     * @param element which we want to check
     * @return if element is present
     */
    public boolean isElementPresent(WebElement element)
    {
        try {
            element.isDisplayed();
        }catch (NoSuchElementException e)
        {
            return false;
        }
        return true;
    }

    /**
     * navigate to address
     * @param url of the address
     */
    public void goToURL(String url)
    {
        driver.get(url);
    }

    public void waitForSeconds(long seconds){
        try {
            Thread.sleep(1000 * seconds);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


}
