Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
POM_page_factory_exercise
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
Shaphen Pangburn
POM_page_factory_exercise
Commits
9feaba17
Commit
9feaba17
authored
Apr 14, 2021
by
Shaphen Pangburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Proterty results to key-value pairs for less cluttered logic in test file
parent
93ec5ee6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
24 deletions
+17
-24
PropertyValues.java
...ava/com/nisum/pompagefactory/practice/PropertyValues.java
+9
-12
SetWebDriver.java
.../java/com/nisum/pompagefactory/practice/SetWebDriver.java
+1
-0
TestConfirmAccountDetails.java
...pagefactory/practice/tests/TestConfirmAccountDetails.java
+7
-12
No files found.
src/main/java/com/nisum/pompagefactory/practice/PropertyValues.java
View file @
9feaba17
...
@@ -3,15 +3,13 @@ package com.nisum.pompagefactory.practice;
...
@@ -3,15 +3,13 @@ package com.nisum.pompagefactory.practice;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.Arrays
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Properties
;
public
class
PropertyValues
{
public
class
PropertyValues
{
List
<
String
>
results
;
Map
<
String
,
String
>
mapResults
=
new
HashMap
<>()
;
InputStream
inputStream
;
InputStream
inputStream
;
public
List
<
String
>
getPropValues
()
throws
IOException
{
public
Map
<
String
,
String
>
getPropValues
()
throws
IOException
{
try
{
try
{
Properties
prop
=
new
Properties
();
Properties
prop
=
new
Properties
();
String
propFileName
=
"application.properties"
;
String
propFileName
=
"application.properties"
;
...
@@ -24,13 +22,12 @@ public class PropertyValues {
...
@@ -24,13 +22,12 @@ public class PropertyValues {
throw
new
FileNotFoundException
(
"property file "
+
propFileName
+
" not found"
);
throw
new
FileNotFoundException
(
"property file "
+
propFileName
+
" not found"
);
}
}
String
firstname
=
prop
.
getProperty
(
"firstname"
);
mapResults
.
put
(
"firstname"
,
prop
.
getProperty
(
"firstname"
)
);
String
lastname
=
prop
.
getProperty
(
"lastname"
);
mapResults
.
put
(
"lastname"
,
prop
.
getProperty
(
"lastname"
)
);
String
email
=
prop
.
getProperty
(
"email"
);
mapResults
.
put
(
"email"
,
prop
.
getProperty
(
"email"
)
);
String
password
=
prop
.
getProperty
(
"password"
);
mapResults
.
put
(
"password"
,
prop
.
getProperty
(
"password"
)
);
String
phone
=
prop
.
getProperty
(
"phone"
);
mapResults
.
put
(
"phone"
,
prop
.
getProperty
(
"phone"
)
);
results
=
Arrays
.
asList
(
firstname
,
lastname
,
email
,
password
,
phone
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Exception: "
+
e
);
System
.
out
.
println
(
"Exception: "
+
e
);
}
finally
{
}
finally
{
...
@@ -38,6 +35,6 @@ public class PropertyValues {
...
@@ -38,6 +35,6 @@ public class PropertyValues {
inputStream
.
close
();
inputStream
.
close
();
}
}
return
r
esults
;
return
mapR
esults
;
}
}
}
}
src/main/java/com/nisum/pompagefactory/practice/SetWebDriver.java
View file @
9feaba17
...
@@ -10,6 +10,7 @@ public class SetWebDriver {
...
@@ -10,6 +10,7 @@ public class SetWebDriver {
switch
(
type
){
switch
(
type
){
case
"chrome"
:
case
"chrome"
:
System
.
setProperty
(
"webdriver.chrome.driver"
,
"/Users/spangburn/drivers/chromedriver"
);
System
.
setProperty
(
"webdriver.chrome.driver"
,
"/Users/spangburn/drivers/chromedriver"
);
break
;
case
"firefox"
:
case
"firefox"
:
// code
// code
case
"Safari"
:
case
"Safari"
:
...
...
src/test/java/com/nisum/pompagefactory/practice/tests/TestConfirmAccountDetails.java
View file @
9feaba17
...
@@ -14,6 +14,7 @@ import org.openqa.selenium.support.ui.WebDriverWait;
...
@@ -14,6 +14,7 @@ import org.openqa.selenium.support.ui.WebDriverWait;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
public
class
TestConfirmAccountDetails
{
public
class
TestConfirmAccountDetails
{
...
@@ -21,13 +22,7 @@ public class TestConfirmAccountDetails {
...
@@ -21,13 +22,7 @@ public class TestConfirmAccountDetails {
public
void
testAccountSettingsInformation
()
throws
InterruptedException
,
IOException
{
public
void
testAccountSettingsInformation
()
throws
InterruptedException
,
IOException
{
// get application.properties values and set WebDriver properties
// get application.properties values and set WebDriver properties
PropertyValues
properties
=
new
PropertyValues
();
PropertyValues
properties
=
new
PropertyValues
();
List
<
String
>
props
=
properties
.
getPropValues
();
Map
<
String
,
String
>
props
=
properties
.
getPropValues
();
String
email
=
props
.
get
(
2
);
String
password
=
props
.
get
(
3
);
String
firstName
=
props
.
get
(
0
);
String
lastName
=
props
.
get
(
1
);
String
phoneNumber
=
props
.
get
(
4
);
WebDriver
driver
=
new
SetWebDriver
(
"chrome"
).
driver
;
WebDriver
driver
=
new
SetWebDriver
(
"chrome"
).
driver
;
WebDriverWait
wait
=
new
WebDriverWait
(
driver
,
5
);
WebDriverWait
wait
=
new
WebDriverWait
(
driver
,
5
);
...
@@ -37,7 +32,7 @@ public class TestConfirmAccountDetails {
...
@@ -37,7 +32,7 @@ public class TestConfirmAccountDetails {
// Login Action Call
// Login Action Call
LoginPage
loginPage
=
new
LoginPage
(
driver
,
"https://www.safeway.com/"
,
false
);
LoginPage
loginPage
=
new
LoginPage
(
driver
,
"https://www.safeway.com/"
,
false
);
loginPage
.
loginUser
(
email
,
password
);
loginPage
.
loginUser
(
props
.
get
(
"email"
),
props
.
get
(
"password"
)
);
// Navigation to Account Settings
// Navigation to Account Settings
AccountSettingsPage
accountSettingsPage
=
new
AccountSettingsPage
(
driver
);
AccountSettingsPage
accountSettingsPage
=
new
AccountSettingsPage
(
driver
);
...
@@ -45,10 +40,10 @@ public class TestConfirmAccountDetails {
...
@@ -45,10 +40,10 @@ public class TestConfirmAccountDetails {
// Assert Information Matches Application Properties
// Assert Information Matches Application Properties
wait
.
until
(
ExpectedConditions
.
elementToBeClickable
(
accountSettingsPage
.
accountFirstName
));
wait
.
until
(
ExpectedConditions
.
elementToBeClickable
(
accountSettingsPage
.
accountFirstName
));
Assertions
.
assertEquals
(
firstName
,
accountSettingsPage
.
accountFirstName
.
getAttribute
(
"value"
));
Assertions
.
assertEquals
(
props
.
get
(
"firstname"
)
,
accountSettingsPage
.
accountFirstName
.
getAttribute
(
"value"
));
Assertions
.
assertEquals
(
lastName
,
accountSettingsPage
.
accountLastName
.
getAttribute
(
"value"
));
Assertions
.
assertEquals
(
props
.
get
(
"lastname"
)
,
accountSettingsPage
.
accountLastName
.
getAttribute
(
"value"
));
Assertions
.
assertEquals
(
email
,
accountSettingsPage
.
accountEmail
.
getAttribute
(
"value"
));
Assertions
.
assertEquals
(
props
.
get
(
"email"
)
,
accountSettingsPage
.
accountEmail
.
getAttribute
(
"value"
));
Assertions
.
assertEquals
(
p
honeNumber
,
accountSettingsPage
.
accountPhoneNumber
.
getAttribute
(
"value"
));
Assertions
.
assertEquals
(
p
rops
.
get
(
"phone"
)
,
accountSettingsPage
.
accountPhoneNumber
.
getAttribute
(
"value"
));
driver
.
quit
();
driver
.
quit
();
}
}
...
...
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