Commit 3c0e1f16 authored by Shaphen Pangburn's avatar Shaphen Pangburn

Complete functionality with abstracted classes for home page, login, and...

Complete functionality with abstracted classes for home page, login, and account settings. Assert correct account information present
parent a1624c3a
......@@ -11,14 +11,14 @@ import java.util.List;
public class AccountSettings {
WebDriver driver;
@FindBy(id = "input-firstName")
WebElement accountFirstName;
@FindBy(id = "input-lastName")
WebElement accountLastName;
@FindBy(id = "emailIdaccount")
WebElement accountEmail;
@FindBy(id = "phoneNumber")
WebElement accountPhoneNumber;
@FindBy(xpath = "//*[@id=\"input-firstName\"]")
public WebElement accountFirstName;
@FindBy(xpath = "//*[@id=\"input-lastName\"]")
public WebElement accountLastName;
@FindBy(xpath = "//*[@id=\"emailIdaccount\"]")
public WebElement accountEmail;
@FindBy(xpath = "//*[@id=\"phoneNumber\"]")
public WebElement accountPhoneNumber;
public AccountSettings(WebDriver driver) {
this.driver = driver;
......@@ -32,24 +32,30 @@ public class AccountSettings {
home.getAccountSettingsButton().click();
}
public static void main(String[] args) throws InterruptedException, IOException {
// get application.properties values and set ChromeDriver
PropertyValues properties = new PropertyValues();
List<String> props = properties.getPropValues();
System.setProperty("webdriver.chrome.driver", "/Users/spangburn/drivers/chromedriver");
WebDriver driver = new ChromeDriver();
// login
String username = props.get(2);
String password = props.get(3);
LoginPage login = new LoginPage(driver, "https://www.safeway.com/", true);
login.loginUser(driver,"https://www.safeway.com/", username, password);
Thread.sleep(5000);
// Navigate to account settings
AccountSettings accountSettings = new AccountSettings(driver);
accountSettings.goToAccountSettings();
Thread.sleep(5000);
driver.close();
}
// public static void main(String[] args) throws InterruptedException, IOException {
// // get application.properties values and set ChromeDriver
// PropertyValues properties = new PropertyValues();
// List<String> props = properties.getPropValues();
// System.setProperty("webdriver.chrome.driver", "/Users/spangburn/drivers/chromedriver");
// WebDriver driver = new ChromeDriver();
//
// // login
// String username = props.get(2);
// String password = props.get(3);
// LoginPage login = new LoginPage(driver, "https://www.safeway.com/", true);
// login.loginUser(driver,"https://www.safeway.com/", username, password);
// Thread.sleep(5000);
//
// // Navigate to account settings
// AccountSettings accountSettings = new AccountSettings(driver);
// accountSettings.goToAccountSettings();
// Thread.sleep(5000);
//
// System.out.println(accountSettings.accountFirstName.getAttribute("value"));
// System.out.println(accountSettings.accountLastName.getAttribute("value"));
// System.out.println(accountSettings.accountEmail.getAttribute("value"));
// System.out.println(accountSettings.accountPhoneNumber.getAttribute("value"));
//
// driver.close();
// }
}
......@@ -9,7 +9,7 @@ import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
class LoginPage {
public class LoginPage {
WebDriver driver;
String url;
......@@ -36,20 +36,20 @@ class LoginPage {
getSignInButton().click();
}
public static void main(String[] args) throws IOException, InterruptedException {
// get application.properties values and set ChromeDriver
PropertyValues properties = new PropertyValues();
List<String> props = properties.getPropValues();
System.setProperty("webdriver.chrome.driver", "/Users/spangburn/drivers/chromedriver");
WebDriver driver = new ChromeDriver();
// set username and password variables and create login scenario
String username = props.get(2);
String password = props.get(3);
LoginPage login = new LoginPage(driver, "https://www.safeway.com/", true);
login.loginUser(driver,"https://www.safeway.com/", username, password);
// public static void main(String[] args) throws IOException, InterruptedException {
// // get application.properties values and set ChromeDriver
// PropertyValues properties = new PropertyValues();
// List<String> props = properties.getPropValues();
// System.setProperty("webdriver.chrome.driver", "/Users/spangburn/drivers/chromedriver");
// WebDriver driver = new ChromeDriver();
//
// // set username and password variables and create login scenario
// String username = props.get(2);
// String password = props.get(3);
// LoginPage login = new LoginPage(driver, "https://www.safeway.com/", true);
// login.loginUser(driver,"https://www.safeway.com/", username, password);
// Thread.sleep(5000);
// driver.close();
}
// }
}
package com.nisum.pompagefactory.practice.tests;
import org.junit.jupiter.api.*;
import org.openqa.selenium.By;
import com.nisum.pompagefactory.practice.AccountSettings;
import com.nisum.pompagefactory.practice.LoginPage;
import com.nisum.pompagefactory.practice.PropertyValues;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.io.IOException;
import java.util.List;
public class TestConfirmAccountDetails {
@Test
public void testSafewayLogin() throws InterruptedException {
// setup
public void testAccountSettingsInformation() throws InterruptedException, IOException {
// get application.properties values and set ChromeDriver
PropertyValues properties = new PropertyValues();
List<String> props = properties.getPropValues();
String email = props.get(2);
String password = props.get(3);
String firstName = props.get(0);
String lastName = props.get(1);
String phoneNumber = props.get(4);
System.setProperty("webdriver.chrome.driver", "/Users/spangburn/drivers/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("https://www.safeway.com/");
Thread.sleep(1000);
// navigate Sign In
WebElement signInDropdown = driver.findElement(By.linkText("Sign In / Up"));
signInDropdown.click();
Thread.sleep(1000);
WebElement signInButton = driver.findElement(By.id("sign-in-modal-link"));
signInButton.click();
Thread.sleep(2000);
// login
WebElement userEmail = driver.findElement(By.id("label-email"));
WebElement userPassword = driver.findElement(By.id("label-password"));
WebElement trySignIn = driver.findElement(By.id("btnSignIn"));
userEmail.sendKeys("zackroc@gmail.com");
userPassword.sendKeys("password123");
trySignIn.click();
Thread.sleep(3000);
// Navigate Account Settings
WebElement accountDropdown = driver.findElement(By.linkText("Account"));
accountDropdown.click();
Thread.sleep(1000);
WebElement accountSettingsButton = driver.findElement(By.xpath("//*[@id=\"menu\"]/div[1]/ul/li[4]/a"));
accountSettingsButton.click();
Thread.sleep(3000);
// Assert Account Information Exists
WebElement getAccountFirstName = driver.findElement(By.id("input-firstName"));
WebElement getAccountLastName = driver.findElement(By.id("input-lastName"));
WebElement getAccountEmail = driver.findElement(By.id("emailIdaccount"));
WebElement getAccountPhoneNumber = driver.findElement(By.id("phoneNumber"));
Assertions.assertEquals("Chef", getAccountFirstName.getAttribute("value"));
Assertions.assertEquals("Koo", getAccountLastName.getAttribute("value"));
Assertions.assertEquals("zackroc@gmail.com", getAccountEmail.getAttribute("value"));
Assertions.assertEquals("5103063656", getAccountPhoneNumber.getAttribute("value"));
LoginPage loginPage = new LoginPage(driver, "https://www.safeway.com/", true);
loginPage.loginUser(driver,"https://www.safeway.com/", email, password);
Thread.sleep(5000);
// Navigate to account settings
AccountSettings accountSettings = new AccountSettings(driver);
accountSettings.goToAccountSettings();
Thread.sleep(5000);
// Assert Information is correct
Assertions.assertEquals(firstName, accountSettings.accountFirstName.getAttribute("value"));
Assertions.assertEquals(lastName, accountSettings.accountLastName.getAttribute("value"));
Assertions.assertEquals(email, accountSettings.accountEmail.getAttribute("value"));
Assertions.assertEquals(phoneNumber, accountSettings.accountPhoneNumber.getAttribute("value"));
driver.quit();
}
}
package com.nisum.pompagefactory.practice.tests;
import org.junit.jupiter.api.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class TestConfirmAccountDetailsSingleClass {
@Test
public void testSafewayLogin() throws InterruptedException {
// setup
System.setProperty("webdriver.chrome.driver", "/Users/spangburn/drivers/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("https://www.safeway.com/");
Thread.sleep(1000);
// navigate Sign In
WebElement signInDropdown = driver.findElement(By.linkText("Sign In / Up"));
signInDropdown.click();
Thread.sleep(1000);
WebElement signInButton = driver.findElement(By.id("sign-in-modal-link"));
signInButton.click();
Thread.sleep(2000);
// login
WebElement userEmail = driver.findElement(By.id("label-email"));
WebElement userPassword = driver.findElement(By.id("label-password"));
WebElement trySignIn = driver.findElement(By.id("btnSignIn"));
userEmail.sendKeys("zackroc@gmail.com");
userPassword.sendKeys("password123");
trySignIn.click();
Thread.sleep(3000);
// Navigate Account Settings
WebElement accountDropdown = driver.findElement(By.linkText("Account"));
accountDropdown.click();
Thread.sleep(1000);
WebElement accountSettingsButton = driver.findElement(By.xpath("//*[@id=\"menu\"]/div[1]/ul/li[4]/a"));
accountSettingsButton.click();
Thread.sleep(3000);
// Assert Account Information Exists
WebElement getAccountFirstName = driver.findElement(By.id("input-firstName"));
WebElement getAccountLastName = driver.findElement(By.id("input-lastName"));
WebElement getAccountEmail = driver.findElement(By.id("emailIdaccount"));
WebElement getAccountPhoneNumber = driver.findElement(By.id("phoneNumber"));
Assertions.assertEquals("Chef", getAccountFirstName.getAttribute("value"));
Assertions.assertEquals("Koo", getAccountLastName.getAttribute("value"));
Assertions.assertEquals("zackroc@gmail.com", getAccountEmail.getAttribute("value"));
Assertions.assertEquals("5103063656", getAccountPhoneNumber.getAttribute("value"));
driver.quit();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment