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;
import com.nisum.pompagefactory.practice.pages.HomePage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
......@@ -27,16 +28,18 @@ public class AccountSettingsPage {
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() {
WebDriverWait wait = new WebDriverWait(driver, 5);
// setup
HomePage home = new HomePage(driver, "https://www.safeway.com/", false);
wait.until(ExpectedConditions.elementToBeClickable(home.getAccountDropdown()));
home.getAccountDropdown().click();
// click account dropdown menu
wait.until(ExpectedConditions.elementToBeClickable(getAccountDropdown()));
getAccountDropdown().click();
// click account settings button
wait.until(ExpectedConditions.elementToBeClickable(home.getAccountSettingsButton()));
home.getAccountSettingsButton().click();
wait.until(ExpectedConditions.elementToBeClickable(getAccountSettingsButton()));
getAccountSettingsButton().click();
}
}
......@@ -19,8 +19,6 @@ public class HomePage {
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 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() {
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