Commit 61f0fef1 authored by Shaphen Pangburn's avatar Shaphen Pangburn

Refactor Account Settings to not rely on instantiating new instances of the HomePage class

parent 0cbbb44c
package com.nisum.pompagefactory.practice.pages; package com.nisum.pompagefactory.practice.pages;
import com.nisum.pompagefactory.practice.pages.HomePage; import com.nisum.pompagefactory.practice.pages.HomePage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
...@@ -27,16 +28,18 @@ public class AccountSettingsPage { ...@@ -27,16 +28,18 @@ public class AccountSettingsPage {
PageFactory.initElements(this.driver, this); PageFactory.initElements(this.driver, this);
} }
public WebElement getAccountDropdown() { return driver.findElement(By.linkText("Account")); }
public WebElement getAccountSettingsButton() { return driver.findElement(By.xpath("//*[@id=\"menu\"]/div[1]/ul/li[4]/a")); }
public void goToAccountSettings() { public void goToAccountSettings() {
WebDriverWait wait = new WebDriverWait(driver, 5); WebDriverWait wait = new WebDriverWait(driver, 5);
// setup // click account dropdown menu
HomePage home = new HomePage(driver, "https://www.safeway.com/", false); wait.until(ExpectedConditions.elementToBeClickable(getAccountDropdown()));
wait.until(ExpectedConditions.elementToBeClickable(home.getAccountDropdown())); getAccountDropdown().click();
home.getAccountDropdown().click();
// click account settings button // click account settings button
wait.until(ExpectedConditions.elementToBeClickable(home.getAccountSettingsButton())); wait.until(ExpectedConditions.elementToBeClickable(getAccountSettingsButton()));
home.getAccountSettingsButton().click(); getAccountSettingsButton().click();
} }
} }
...@@ -19,8 +19,6 @@ public class HomePage { ...@@ -19,8 +19,6 @@ public class HomePage {
public WebElement getMenuNav() { return driver.findElement(By.linkText("Sign In / Up")); } public WebElement getMenuNav() { return driver.findElement(By.linkText("Sign In / Up")); }
public WebElement getSignInButton() { return driver.findElement(By.id("sign-in-modal-link")); } public WebElement getSignInButton() { return driver.findElement(By.id("sign-in-modal-link")); }
public WebElement getAccountDropdown() { return driver.findElement(By.linkText("Account")); }
public WebElement getAccountSettingsButton() { return driver.findElement(By.xpath("//*[@id=\"menu\"]/div[1]/ul/li[4]/a")); }
public void navigateToLogin() { public void navigateToLogin() {
WebDriverWait wait = new WebDriverWait(driver, 5); WebDriverWait wait = new WebDriverWait(driver, 5);
......
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