package pwa_creditfair;

import java.util.List;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class pwa_login extends pwa_config {

	public void pwaapplogin() throws InterruptedException {
		Actions actions = new Actions(driver);
		WebDriverWait wait = new WebDriverWait(driver, 5000);
		Scanner console = new Scanner(System.in);
		Thread.sleep(5000);
		for (int i = 0; i <= 3; i++) {
			driver.manage().timeouts().implicitlyWait(500, TimeUnit.SECONDS);
			driver.findElement(By.xpath("//*[@id=\"app\"]/div/div/div[2]/div")).click();
		}
		driver.findElement(By.id("phone")).sendKeys("0000001621");
		driver.findElement(By.xpath("//*[@id=\"app\"]/div/div/div/section/div/div/div[2]/form/div[3]/button[1]"))
				.click();
		Thread.sleep(5000);
		// System.out.println("Pls Click Enetr to contnue..");
		// System.out.print("Enter OTP" + console.nextLine());
		// String status = console.nextLine();
		// int statusint = Integer.parseInt(status);
		// String otp = Integer.toString(statusint);
		driver.findElement(By.xpath("//*[@id=\"otp\"]")).sendKeys("162116");
		// driver.findElement(By.xpath("//*[@id=\"otp\"]")).sendKeys(otp);
		driver.findElement(By.xpath("//*[@id=\"app\"]/div/div/div/section/div/div/div[2]/form/div[3]/button[1]"))
				.click();
		System.out.println("Login Successfully");
		Thread.sleep(5000);
		driver.manage().timeouts().implicitlyWait(2000, TimeUnit.SECONDS);
		driver.findElement(By.xpath("//*[@id=\"___reactour\"]/div[2]/button")).click();
		driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
		driver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[1]/header/div/button")).click();
		driver.manage().timeouts().implicitlyWait(2000, TimeUnit.SECONDS);
		driver.findElement(By.xpath("/html/body/div[3]/div[2]/ul[1]/div/div[4]")).click();
		driver.manage().timeouts().implicitlyWait(2000, TimeUnit.SECONDS);
		driver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[1]/main/div[3]/div/form/div")).click();
		List<WebElement> citys = driver.findElements(By.xpath("//*[@id=\"menu-center\"]/div[2]/ul/li"));
		for (WebElement location : citys) {
			System.out.println(location.getText());
			if ("Mumbai".equals(location.getText())) {
				location.click();
			}
		}
		driver.findElement(By.xpath("//*[@id=\"app\"]/div/div[1]/div[1]/main/div[3]/div/div[1]")).click();
		// System.out.println(elems);
	}
}
