Commit 2358aa86 authored by dbhuller's avatar dbhuller

test goes to home page, logs in, goes to accnt settings and validates user info

parents
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="pom-pf-project" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>pom-pf-project</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.example;
import org.openqa.selenium.By;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.concurrent.TimeUnit;
public class AccountSettingsPage {
WebDriver driver;
public AccountSettingsPage(WebDriver driver) {
this.driver = driver;
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}
public WebElement getAccountModal() {
return driver.findElement(By.xpath("/html/body/div[1]/div/div/div[1]/div/div/div/div[3]/div[2]/div[1]/div/div/div[3]/ul/li[1]/a/span[1]"));
}
public WebElement getAccountSettingsPage() {
return driver.findElement(By.xpath("//*[@id=\"menu\"]/div[1]/ul/li[4]/a"));
}
public WebElement getFirstNameField() {
return driver.findElement(By.xpath("//*[@id=\"input-firstName\"]"));
}
public WebElement getLastNameField() {
return driver.findElement(By.xpath("//*[@id=\"input-lastName\"]"));
}
public WebElement getEmailField() {
return driver.findElement(By.xpath("//*[@id=\"emailIdaccount\"]"));
}
public void validateAccountInfo() {
validateFirstNameField();
validateLastNameField();
validateEmailField();
}
public void validateFirstNameField() {
WebElement firstname = getFirstNameField();
assertEquals("Nisum", firstname.getAttribute("value"), "Values Dont Match");
}
public void validateLastNameField() {
WebElement lastname = getLastNameField();
assertEquals("TestAcct", lastname.getAttribute("value"), "Values Dont Match");
}
public void validateEmailField() {
WebElement email = getEmailField();
assertEquals("vkrijegccvsknuvnpv@miucce.com", email.getAttribute("value"), "Values Dont Match");
}
public void navigateToAccountSettingsPage() {
try {
getAccountModal().click();
getAccountSettingsPage().click();
} catch (StaleElementReferenceException e) {
WebDriverWait wdw = new WebDriverWait(driver, 5);
wdw.until(ExpectedConditions.elementToBeClickable(getAccountModal()));
getAccountModal().click();
getAccountSettingsPage().click();
}
}
}
package com.example;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class HomePage {
WebDriver driver;
String url;
public HomePage(WebDriver driver, String url) {
this.driver = driver;
this.url = url;
}
public WebElement getSignInDropDown() {
return driver.findElement(By.xpath("/html/body/div[1]/div/div/div[1]/div/div/div/div[3]/div[2]/div[1]/div/div/div" +
"[3]/ul/li[1]/a/span[1]"));
}
public WebElement getSignIn() {
return driver.findElement(By.id("sign-in-modal-link"));
}
public void navigateToLoginPage(String url) {
driver.get(url);
getSignInDropDown().click();
getSignIn().click();
}
}
package com.example;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import java.util.concurrent.TimeUnit;
public class Login {
WebDriver driver;
public Login(WebDriver driver) {
this.driver = driver;
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}
public WebElement getUsernameInput() {
return driver.findElement(By.id("label-email"));
}
public WebElement getPasswordInput() {
return driver.findElement(By.id(("label-password")));
}
public WebElement getSubmitButton() {
return driver.findElement(By.id("btnSignIn"));
}
public void login(String username, String password) {
getUsernameInput().sendKeys(username);
getPasswordInput().sendKeys(password);
getSubmitButton().click();
}
}
package com.example;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class SafewayTest {
// WebDriver driver;
String url = "http://www.safeway.com";
final String username = "vkrijegccvsknuvnpv@miucce.com";
final String password = "12345678";
public static WebDriver initDriver() {
System.setProperty("webdriver.chrome.driver", "/Users/dbhuller/Documents/WebDrivers/chromedriver");
WebDriver driver = new ChromeDriver();
return driver;
}
@Test
public void testLogin() {
WebDriver driver = initDriver();
HomePage hp = new HomePage(driver, url);
hp.navigateToLoginPage(url);
Login l = new Login(driver);
l.login(username, password);
AccountSettingsPage asp = new AccountSettingsPage(driver);
asp.navigateToAccountSettingsPage();
asp.validateAccountInfo();
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