package stepdefination;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
public class Stepamazon {
WebDriver driver;
@Given("^User open chromeBrowser and start application$")
public void user_open_chromeBrowser_and_start_application() throws Exception {
System.setProperty("webdriver.chrome.driver","F:\\SELENIUM INSTALLS\\WEBDRIVERS\\chromedriver.exe");
driver=new ChromeDriver();
driver.manage().window().maximize();
Thread.sleep(1000);
//click sign button:
driver.findElement(By.xpath(".//*[text() = 'Hello. Sign in']")).click();
Thread.sleep(600);
}
@Then("^Enter Valid \"([^\"]*)\" and \"([^\"]*)\"$")
public void enter_Valid_and(String username, String password) throws Exception {
driver.findElement(By.name("email")).sendKeys(username);
driver.findElement(By.id("continue")).click();
driver.findElement(By.name("password")).sendKeys(password);
driver.findElement(By.id("signInSubmit")).click();
Thread.sleep(600);
}
@Then("^User open amzon user account successfully$")
public void user_open_amzon_user_account_successfully() throws Exception {
driver.findElement(By.xpath(".//*[text()='Hello, Sirisha']")) ;
Thread.sleep(1000);
}
@Then("^Close site$")
public void close_site() throws Exception {
WebElement e = driver.findElement(By.xpath(".//*[@id='nav-item-signout-sa']/span[class = 'nav-text' or text() ='Sign Out']"));
Actions a = new Actions(driver);
a.moveToElement(e).build().perform();
Thread.sleep(1000);
}
@Then("^Close chrome browser$")
public void close_chrome_browser() throws Exception {
driver.close();
}
}