package creditfair_admin_maven_uipages;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;

import creditfair_admin_maven_config.DbConnection;

public class AdminLogin extends DbConnection{
	public AdminLogin() throws Exception {
		super();
		// TODO Auto-generated constructor stub
	}

	DbConnection dbconnection = new DbConnection();
	
	WebDriver driver;

	public void AdminLogin(WebDriver driver) {
		this.driver = driver;

	}

	@FindBy(how = How.NAME, using = "username")
	@CacheLookup
	WebElement username;

	@FindBy(how = How.NAME, using = "password")
	@CacheLookup
	WebElement password;

	@FindBy(how = How.ID, using = "m_login_signin_submit")
	@CacheLookup
	WebElement login;
	
	@FindBy(how = How.XPATH, using = "/html/body/div/div/div/div/div[2]/form/div[6]/div")
	@CacheLookup
	WebElement signotp;
	
	@FindBy(how = How.XPATH, using = "/html/body/div/div/div/div/div[2]/form/div[6]/div[1]/div/input")
	@CacheLookup
	WebElement phonenumber;
	
	@FindBy(how = How.XPATH, using = "/html/body/div/div/div/div/div[2]/form/div[6]/div[2]")
	@CacheLookup
	WebElement requestotp;
	
	@FindBy(how = How.XPATH, using = "/html/body/div/div/div/div/div[2]/form/div[6]/div[1]/div/input[1]")
	@CacheLookup
	WebElement enterotp;
	
	@FindBy(how = How.XPATH, using = "/html/body/div/div/div/div/div[2]/form/div[6]/div[2]")
	@CacheLookup
	WebElement submitop;
	
	
	
	

	public void loginAdmin(String user, String pwd) throws InterruptedException {
		try {
			username.sendKeys(user);
			password.sendKeys(pwd);
			Thread.sleep(2000);
			login.click();
			Thread.sleep(2000);
		}

		catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public void prodloginAdmin () throws InterruptedException
	{
		
		signotp.click();
        phonenumber.sendKeys("7208239249");
        requestotp.click();
	    Thread.sleep(2000);
	    enterotp.sendKeys(dbconnection.pullOtp());
	    Thread.sleep(2000);
	    submitop.click();
		
	}
}
