Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Selenium-Chrome-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
Kyle Muldoon
Selenium-Chrome-POM
Commits
f94de708
Commit
f94de708
authored
Apr 13, 2021
by
Kyle Muldoon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored to break entire login process into subcomponents
parent
07dedaad
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
130 additions
and
28 deletions
+130
-28
pom.xml
pom.xml
+6
-0
AccountSettingsPOM.java
src/test/java/AccountSettingsPOM.java
+20
-0
HomePagePF.java
src/test/java/PageComponents/HomePagePF.java
+34
-0
LoginModalPF.java
src/test/java/PageComponents/LoginModalPF.java
+5
-23
RightSideBarPF.java
src/test/java/PageComponents/RightSideBarPF.java
+29
-0
SafewayLoginTest.java
src/test/java/SafewayLoginTest.java
+13
-5
TODO.md
src/test/java/TODO.md
+23
-0
SafewayLoginTest.class
target/test-classes/SafewayLoginTest.class
+0
-0
No files found.
pom.xml
View file @
f94de708
...
@@ -33,6 +33,12 @@
...
@@ -33,6 +33,12 @@
<artifactId>
selenium-java
</artifactId>
<artifactId>
selenium-java
</artifactId>
<version>
3.141.59
</version>
<version>
3.141.59
</version>
</dependency>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.13.2
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
...
...
src/test/java/AccountSettingsPOM.java
0 → 100644
View file @
f94de708
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.ui.WebDriverWait
;
public
class
AccountSettingsPOM
{
WebDriver
driver
;
WebDriverWait
wdw
;
WebElement
expandAccountOptionsButton
;
WebElement
accountSettingsButton
;
WebElement
userNameInputBox
;
WebElement
userPasswordInputBox
;
WebElement
signInButton
;
}
src/test/java/PageComponents/HomePagePF.java
0 → 100644
View file @
f94de708
package
PageComponents
;
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
HomePagePF
{
WebDriver
driver
;
WebDriverWait
wdw
;
@FindBy
(
how
=
How
.
PARTIAL_LINK_TEXT
,
using
=
"Sign In / Up"
)
WebElement
expandLoginOptionsButton
;
public
HomePagePF
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
this
.
wdw
=
new
WebDriverWait
(
this
.
driver
,
1
);
PageFactory
.
initElements
(
driver
,
this
);
}
public
void
visitSafewayHomepage
()
{
driver
.
get
(
"https://www.safeway.com/"
);
}
public
void
revealRightSidebar
()
{
wdw
.
until
(
ExpectedConditions
.
elementToBeClickable
(
expandLoginOptionsButton
));
expandLoginOptionsButton
.
click
();
}
}
src/test/java/
Login
PF.java
→
src/test/java/
PageComponents/LoginModal
PF.java
View file @
f94de708
package
PageComponents
;
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
;
import
org.openqa.selenium.support.How
;
import
org.openqa.selenium.support.How
;
import
org.openqa.selenium.support.PageFactory
;
import
org.openqa.selenium.support.PageFactory
;
import
org.openqa.selenium.support.ui.ExpectedCondition
;
import
org.openqa.selenium.support.ui.ExpectedConditions
;
import
org.openqa.selenium.support.ui.ExpectedConditions
;
import
org.openqa.selenium.support.ui.WebDriverWait
;
import
org.openqa.selenium.support.ui.WebDriverWait
;
import
sun.security.util.Password
;
import
java.util.concurrent.TimeUnit
;
public
class
LoginPF
{
public
class
Login
Modal
PF
{
WebDriver
driver
;
WebDriver
driver
;
WebDriverWait
wdw
;
WebDriverWait
wdw
;
@FindBy
(
how
=
How
.
PARTIAL_LINK_TEXT
,
using
=
"Sign In / Up"
)
WebElement
expandLoginOptionsButton
;
@FindBy
(
how
=
How
.
ID
,
using
=
"sign-in-modal-link"
)
WebElement
revealLoginModalButton
;
@FindBy
(
how
=
How
.
ID
,
using
=
"label-email"
)
@FindBy
(
how
=
How
.
ID
,
using
=
"label-email"
)
WebElement
userNameInputBox
;
WebElement
userNameInputBox
;
...
@@ -29,19 +21,12 @@ public class LoginPF {
...
@@ -29,19 +21,12 @@ public class LoginPF {
@FindBy
(
how
=
How
.
ID
,
using
=
"btnSignIn"
)
@FindBy
(
how
=
How
.
ID
,
using
=
"btnSignIn"
)
WebElement
signInButton
;
WebElement
signInButton
;
public
LoginPF
(
WebDriver
driver
)
{
public
Login
Modal
PF
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
this
.
driver
=
driver
;
this
.
wdw
=
new
WebDriverWait
(
this
.
driver
,
1
);
this
.
wdw
=
new
WebDriverWait
(
this
.
driver
,
1
);
PageFactory
.
initElements
(
driver
,
this
);
PageFactory
.
initElements
(
driver
,
this
);
}
}
public
void
revealLoginModal
()
{
wdw
.
until
(
ExpectedConditions
.
elementToBeClickable
(
expandLoginOptionsButton
));
expandLoginOptionsButton
.
click
();
wdw
.
until
(
ExpectedConditions
.
elementToBeClickable
(
revealLoginModalButton
));
revealLoginModalButton
.
click
();
}
public
void
fillUserInfo
(
String
userName
,
String
password
)
{
public
void
fillUserInfo
(
String
userName
,
String
password
)
{
wdw
.
until
(
ExpectedConditions
.
elementToBeClickable
(
userNameInputBox
));
wdw
.
until
(
ExpectedConditions
.
elementToBeClickable
(
userNameInputBox
));
wdw
.
until
(
ExpectedConditions
.
elementToBeClickable
(
userPasswordInputBox
));
wdw
.
until
(
ExpectedConditions
.
elementToBeClickable
(
userPasswordInputBox
));
...
@@ -49,10 +34,7 @@ public class LoginPF {
...
@@ -49,10 +34,7 @@ public class LoginPF {
this
.
userPasswordInputBox
.
sendKeys
(
password
);
this
.
userPasswordInputBox
.
sendKeys
(
password
);
}
}
public
void
login
(
String
username
,
String
password
)
{
public
void
sendCredentials
()
{
revealLoginModal
();
fillUserInfo
(
username
,
password
);
wdw
.
until
(
ExpectedConditions
.
elementToBeClickable
(
signInButton
));
signInButton
.
click
();
signInButton
.
click
();
}
}
...
...
src/test/java/PageComponents/RightSideBarPF.java
0 → 100644
View file @
f94de708
package
PageComponents
;
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
RightSideBarPF
{
WebDriver
driver
;
WebDriverWait
wdw
;
@FindBy
(
how
=
How
.
ID
,
using
=
"sign-in-modal-link"
)
WebElement
revealLoginModalButton
;
public
RightSideBarPF
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
this
.
wdw
=
new
WebDriverWait
(
this
.
driver
,
1
);
PageFactory
.
initElements
(
driver
,
this
);
}
public
void
revealLoginModal
()
{
wdw
.
until
(
ExpectedConditions
.
elementToBeClickable
(
revealLoginModalButton
));
revealLoginModalButton
.
click
();
}
}
src/test/java/SafewayLoginTest.java
View file @
f94de708
import
PageComponents.HomePagePF
;
import
PageComponents.LoginModalPF
;
import
PageComponents.RightSideBarPF
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.chrome.ChromeDriver
;
import
org.openqa.selenium.chrome.ChromeDriver
;
...
@@ -19,15 +22,21 @@ public class SafewayLoginTest {
...
@@ -19,15 +22,21 @@ public class SafewayLoginTest {
setup
();
setup
();
WebDriver
driver
=
new
ChromeDriver
();
WebDriver
driver
=
new
ChromeDriver
();
LoginPF
loginPF
=
new
LoginPF
(
driver
);
driver
.
get
(
"https://www.safeway.com/"
);
HomePagePF
homePage
=
new
HomePagePF
(
driver
);
loginPF
.
login
(
safewayLoginCreds
.
getProperty
(
"username"
),
safewayLoginCreds
.
getProperty
(
"password"
));
RightSideBarPF
rightSideBar
=
new
RightSideBarPF
(
driver
);
LoginModalPF
loginModal
=
new
LoginModalPF
(
driver
);
homePage
.
visitSafewayHomepage
();
homePage
.
revealRightSidebar
();
rightSideBar
.
revealLoginModal
();
loginModal
.
fillUserInfo
(
safewayLoginCreds
.
getProperty
(
"username"
),
safewayLoginCreds
.
getProperty
(
"password"
));
loginModal
.
sendCredentials
();
Thread
.
sleep
(
10000
);
Thread
.
sleep
(
10000
);
driver
.
quit
();
driver
.
quit
();
}
}
public
void
setup
()
{
public
void
setup
()
{
/////////////////////
/////////////////////
...
@@ -76,5 +85,4 @@ public class SafewayLoginTest {
...
@@ -76,5 +85,4 @@ public class SafewayLoginTest {
ex
.
printStackTrace
();
ex
.
printStackTrace
();
}
}
}
}
}
}
\ No newline at end of file
src/test/java/TODO.md
0 → 100644
View file @
f94de708
Create a maven project and provide all the dependencies.
Use Selenium 3.x.x (latest).
Use TestNG / JUnit.
Write generic code which will work with any type of browser. Browser may be a parameter.
Make appropriate arrangements for identifying the OS and picking up the correct driver for that particular OS.
1.
Assume that you have a user registered on safeway.com. All the details of the account that was registered are stored in a property file.
2.
Create Page Classes for Home Page, Login Page, Account Settings Page.
3.
Verify all the details from the property file using proper testNG/JUnit assertions.
use Page Object Model & Page Factory (like a couple classes using page object model and a couple using page factory.)
---------------
# verify account settings next:
-
get account settings from webpage.
-
assertEqual that they are the expected values.
\ No newline at end of file
target/test-classes/SafewayLoginTest.class
View file @
f94de708
No preview for this file type
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