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; ...@@ -11,14 +11,14 @@ import java.util.List;
public class AccountSettings { public class AccountSettings {
WebDriver driver; WebDriver driver;
@FindBy(id = "input-firstName") @FindBy(xpath = "//*[@id=\"input-firstName\"]")
WebElement accountFirstName; public WebElement accountFirstName;
@FindBy(id = "input-lastName") @FindBy(xpath = "//*[@id=\"input-lastName\"]")
WebElement accountLastName; public WebElement accountLastName;
@FindBy(id = "emailIdaccount") @FindBy(xpath = "//*[@id=\"emailIdaccount\"]")
WebElement accountEmail; public WebElement accountEmail;
@FindBy(id = "phoneNumber") @FindBy(xpath = "//*[@id=\"phoneNumber\"]")
WebElement accountPhoneNumber; public WebElement accountPhoneNumber;
public AccountSettings(WebDriver driver) { public AccountSettings(WebDriver driver) {
this.driver = driver; this.driver = driver;
...@@ -32,24 +32,30 @@ public class AccountSettings { ...@@ -32,24 +32,30 @@ public class AccountSettings {
home.getAccountSettingsButton().click(); home.getAccountSettingsButton().click();
} }
public static void main(String[] args) throws InterruptedException, IOException { // public static void main(String[] args) throws InterruptedException, IOException {
// get application.properties values and set ChromeDriver // // get application.properties values and set ChromeDriver
PropertyValues properties = new PropertyValues(); // PropertyValues properties = new PropertyValues();
List<String> props = properties.getPropValues(); // List<String> props = properties.getPropValues();
System.setProperty("webdriver.chrome.driver", "/Users/spangburn/drivers/chromedriver"); // System.setProperty("webdriver.chrome.driver", "/Users/spangburn/drivers/chromedriver");
WebDriver driver = new ChromeDriver(); // WebDriver driver = new ChromeDriver();
//
// login // // login
String username = props.get(2); // String username = props.get(2);
String password = props.get(3); // String password = props.get(3);
LoginPage login = new LoginPage(driver, "https://www.safeway.com/", true); // LoginPage login = new LoginPage(driver, "https://www.safeway.com/", true);
login.loginUser(driver,"https://www.safeway.com/", username, password); // login.loginUser(driver,"https://www.safeway.com/", username, password);
Thread.sleep(5000); // Thread.sleep(5000);
//
// Navigate to account settings // // Navigate to account settings
AccountSettings accountSettings = new AccountSettings(driver); // AccountSettings accountSettings = new AccountSettings(driver);
accountSettings.goToAccountSettings(); // accountSettings.goToAccountSettings();
Thread.sleep(5000); // Thread.sleep(5000);
driver.close(); //
} // 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; ...@@ -9,7 +9,7 @@ import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
class LoginPage { public class LoginPage {
WebDriver driver; WebDriver driver;
String url; String url;
...@@ -36,20 +36,20 @@ class LoginPage { ...@@ -36,20 +36,20 @@ class LoginPage {
getSignInButton().click(); getSignInButton().click();
} }
public static void main(String[] args) throws IOException, InterruptedException { // public static void main(String[] args) throws IOException, InterruptedException {
// get application.properties values and set ChromeDriver // // get application.properties values and set ChromeDriver
PropertyValues properties = new PropertyValues(); // PropertyValues properties = new PropertyValues();
List<String> props = properties.getPropValues(); // List<String> props = properties.getPropValues();
System.setProperty("webdriver.chrome.driver", "/Users/spangburn/drivers/chromedriver"); // System.setProperty("webdriver.chrome.driver", "/Users/spangburn/drivers/chromedriver");
WebDriver driver = new ChromeDriver(); // WebDriver driver = new ChromeDriver();
//
// set username and password variables and create login scenario // // set username and password variables and create login scenario
String username = props.get(2); // String username = props.get(2);
String password = props.get(3); // String password = props.get(3);
LoginPage login = new LoginPage(driver, "https://www.safeway.com/", true); // LoginPage login = new LoginPage(driver, "https://www.safeway.com/", true);
login.loginUser(driver,"https://www.safeway.com/", username, password); // login.loginUser(driver,"https://www.safeway.com/", username, password);
// Thread.sleep(5000); // Thread.sleep(5000);
// driver.close(); // driver.close();
} // }
} }
package com.nisum.pompagefactory.practice.tests; package com.nisum.pompagefactory.practice.tests;
import org.junit.jupiter.api.*; import com.nisum.pompagefactory.practice.AccountSettings;
import org.openqa.selenium.By; 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.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeDriver;
import java.io.IOException;
import java.util.List;
public class TestConfirmAccountDetails { public class TestConfirmAccountDetails {
@Test @Test
public void testSafewayLogin() throws InterruptedException { public void testAccountSettingsInformation() throws InterruptedException, IOException {
// setup // get application.properties values and set ChromeDriver
System.setProperty("webdriver.chrome.driver", "/Users/spangburn/drivers/chromedriver"); PropertyValues properties = new PropertyValues();
WebDriver driver = new ChromeDriver(); List<String> props = properties.getPropValues();
driver.get("https://www.safeway.com/"); String email = props.get(2);
Thread.sleep(1000); String password = props.get(3);
String firstName = props.get(0);
// navigate Sign In String lastName = props.get(1);
WebElement signInDropdown = driver.findElement(By.linkText("Sign In / Up")); String phoneNumber = props.get(4);
signInDropdown.click();
Thread.sleep(1000); System.setProperty("webdriver.chrome.driver", "/Users/spangburn/drivers/chromedriver");
WebElement signInButton = driver.findElement(By.id("sign-in-modal-link")); WebDriver driver = new ChromeDriver();
signInButton.click();
Thread.sleep(2000); // login
LoginPage loginPage = new LoginPage(driver, "https://www.safeway.com/", true);
// login loginPage.loginUser(driver,"https://www.safeway.com/", email, password);
WebElement userEmail = driver.findElement(By.id("label-email")); Thread.sleep(5000);
WebElement userPassword = driver.findElement(By.id("label-password"));
WebElement trySignIn = driver.findElement(By.id("btnSignIn")); // Navigate to account settings
AccountSettings accountSettings = new AccountSettings(driver);
userEmail.sendKeys("zackroc@gmail.com"); accountSettings.goToAccountSettings();
userPassword.sendKeys("password123"); Thread.sleep(5000);
trySignIn.click();
Thread.sleep(3000); // Assert Information is correct
Assertions.assertEquals(firstName, accountSettings.accountFirstName.getAttribute("value"));
// Navigate Account Settings Assertions.assertEquals(lastName, accountSettings.accountLastName.getAttribute("value"));
WebElement accountDropdown = driver.findElement(By.linkText("Account")); Assertions.assertEquals(email, accountSettings.accountEmail.getAttribute("value"));
accountDropdown.click(); Assertions.assertEquals(phoneNumber, accountSettings.accountPhoneNumber.getAttribute("value"));
Thread.sleep(1000);
WebElement accountSettingsButton = driver.findElement(By.xpath("//*[@id=\"menu\"]/div[1]/ul/li[4]/a")); driver.quit();
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();
}
} }
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