Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pof_pom
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Darrick Yong
pof_pom
Commits
d2acb5ae
Commit
d2acb5ae
authored
Apr 13, 2021
by
Darrick Yong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor property helper and implicit wait
parent
3f6c1d29
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
18 deletions
+22
-18
AccountSettingsPage.java
src/main/java/AccountSettingsPage.java
+9
-0
LoginPage.java
src/main/java/LoginPage.java
+8
-7
GetAccountProperties.java
src/main/java/helpers/GetAccountProperties.java
+3
-5
TestSafeway.java
src/test/java/TestSafeway.java
+2
-6
No files found.
src/main/java/AccountSettingsPage.java
View file @
d2acb5ae
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertAll
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.WebElement
;
import
org.openqa.selenium.support.FindBy
;
import
org.openqa.selenium.support.How
;
import
org.openqa.selenium.support.PageFactory
;
import
org.openqa.selenium.support.ui.ExpectedConditions
;
import
org.openqa.selenium.support.ui.WebDriverWait
;
public
class
AccountSettingsPage
{
WebDriver
driver
;
WebDriverWait
waiter
;
@FindBy
(
how
=
How
.
ID
,
using
=
"input-firstName"
)
WebElement
firstNameInput
;
...
...
@@ -24,10 +29,14 @@ public class AccountSettingsPage {
public
AccountSettingsPage
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
// this.waiter = new WebDriverWait(this.driver, 5);
PageFactory
.
initElements
(
driver
,
this
);
}
public
void
confirmLogin
(
String
firstName
,
String
lastName
,
String
email
,
String
phone
)
{
// this.waiter.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Account Settings")));
assertAll
(
"First name, last name, and email should match account props"
,
()
->
assertEquals
(
firstName
,
firstNameInput
.
getAttribute
(
"value"
)),
()
->
assertEquals
(
lastName
,
lastNameInput
.
getAttribute
(
"value"
)),
...
...
src/main/java/LoginPage.java
View file @
d2acb5ae
...
...
@@ -6,12 +6,11 @@ import org.openqa.selenium.support.ui.WebDriverWait;
public
class
LoginPage
{
WebDriver
driver
;
WebElement
nameInput
;
WebElement
passInput
;
WebElement
submitBtn
;
WebDriverWait
waiter
;
public
LoginPage
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
this
.
waiter
=
new
WebDriverWait
(
this
.
driver
,
5
);
}
public
WebElement
getNameInput
()
{
...
...
@@ -26,17 +25,19 @@ public class LoginPage {
return
driver
.
findElement
(
By
.
id
(
"btnSignIn"
));
}
public
WebDriverWait
getWaiter
()
{
return
new
WebDriverWait
(
this
.
driver
,
5
);
}
//
public WebDriverWait getWaiter() {
//
return new WebDriverWait(this.driver, 5 );
//
}
public
void
login
(
String
username
,
String
password
)
{
getWaiter
()
.
until
(
ExpectedConditions
.
visibilityOfElementLocated
(
By
.
id
(
"btnSignIn"
)));
// this.waiter
.until(ExpectedConditions.visibilityOfElementLocated(By.id("btnSignIn")));
getNameInput
().
sendKeys
(
username
);
getPassInput
().
sendKeys
(
password
);
getSubmitBtn
().
click
();
this
.
waiter
.
until
(
ExpectedConditions
.
visibilityOfElementLocated
(
By
.
linkText
(
"Account"
)));
}
}
src/main/java/helpers/GetAccountProperties.java
View file @
d2acb5ae
...
...
@@ -24,11 +24,9 @@ public class GetAccountProperties {
throw
new
FileNotFoundException
(
"property file '"
+
propFileName
+
"' not found in the classpath"
);
}
res
.
put
(
"email"
,
props
.
getProperty
(
"email"
));
res
.
put
(
"password"
,
props
.
getProperty
(
"password"
));
res
.
put
(
"firstName"
,
props
.
getProperty
(
"firstName"
));
res
.
put
(
"lastName"
,
props
.
getProperty
(
"lastName"
));
res
.
put
(
"phone"
,
props
.
getProperty
(
"phone"
));
props
.
stringPropertyNames
().
forEach
(
prop
->
{
res
.
put
(
prop
,
props
.
getProperty
(
prop
));
});
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
...
...
src/test/java/TestSafeway.java
View file @
d2acb5ae
import
helpers.GetAccountProperties
;
import
org.junit.jupiter.api.Test
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.chrome.ChromeDriver
;
import
org.openqa.selenium.support.ui.ExpectedConditions
;
import
org.openqa.selenium.support.ui.WebDriverWait
;
import
java.io.IOException
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
public
class
TestSafeway
{
...
...
@@ -31,7 +29,7 @@ public class TestSafeway {
}
WebDriver
driver
=
new
ChromeDriver
();
WebDriverWait
waiter
=
new
WebDriverWait
(
driver
,
5
);
driver
.
manage
().
timeouts
().
implicitlyWait
(
3
,
TimeUnit
.
SECONDS
);
driver
.
get
(
"https://www.safeway.com"
);
HomePage
homePage
=
new
HomePage
(
driver
);
...
...
@@ -43,11 +41,9 @@ public class TestSafeway {
LoginPage
loginPage
=
new
LoginPage
(
driver
);
loginPage
.
login
(
email
,
password
);
waiter
.
until
(
ExpectedConditions
.
visibilityOfElementLocated
(
By
.
linkText
(
"Account"
)));
homePage
.
openRightNav
();
rightNavBar
.
openAccountSettings
();
waiter
.
until
(
ExpectedConditions
.
visibilityOfElementLocated
(
By
.
linkText
(
"Account Settings"
)));
AccountSettingsPage
accountSettingsPage
=
new
AccountSettingsPage
(
driver
);
accountSettingsPage
.
confirmLogin
(
firstName
,
lastName
,
email
,
phone
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment