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
07dedaad
Commit
07dedaad
authored
Apr 13, 2021
by
Kyle Muldoon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
got page factory working
parent
22ed1353
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
140 additions
and
3 deletions
+140
-3
demo.jpg
demo.jpg
+0
-0
demoPF.jpg
demoPF.jpg
+0
-0
Login.java
src/test/java/Login.java
+0
-2
LoginPF.java
src/test/java/LoginPF.java
+59
-0
SafewayLoginTest.java
src/test/java/SafewayLoginTest.java
+79
-1
credentials.properties
src/test/resources/credentials.properties
+2
-0
SafewayLoginTest.class
target/test-classes/SafewayLoginTest.class
+0
-0
No files found.
demo.jpg
deleted
100644 → 0
View file @
22ed1353
161 KB
demoPF.jpg
0 → 100644
View file @
07dedaad
70.3 KB
src/test/java/Login.java
deleted
100644 → 0
View file @
22ed1353
package
PACKAGE_NAME
;
public
class
Login
{
}
src/test/java/LoginPF.java
0 → 100644
View file @
07dedaad
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.ExpectedCondition
;
import
org.openqa.selenium.support.ui.ExpectedConditions
;
import
org.openqa.selenium.support.ui.WebDriverWait
;
import
sun.security.util.Password
;
import
java.util.concurrent.TimeUnit
;
public
class
LoginPF
{
WebDriver
driver
;
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"
)
WebElement
userNameInputBox
;
@FindBy
(
how
=
How
.
ID
,
using
=
"label-password"
)
WebElement
userPasswordInputBox
;
@FindBy
(
how
=
How
.
ID
,
using
=
"btnSignIn"
)
WebElement
signInButton
;
public
LoginPF
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
this
.
wdw
=
new
WebDriverWait
(
this
.
driver
,
1
);
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
)
{
wdw
.
until
(
ExpectedConditions
.
elementToBeClickable
(
userNameInputBox
));
wdw
.
until
(
ExpectedConditions
.
elementToBeClickable
(
userPasswordInputBox
));
this
.
userNameInputBox
.
sendKeys
(
userName
);
this
.
userPasswordInputBox
.
sendKeys
(
password
);
}
public
void
login
(
String
username
,
String
password
)
{
revealLoginModal
();
fillUserInfo
(
username
,
password
);
wdw
.
until
(
ExpectedConditions
.
elementToBeClickable
(
signInButton
));
signInButton
.
click
();
}
}
src/test/java/SafewayLoginTest.java
View file @
07dedaad
import
org.junit.jupiter.api.Test
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.chrome.ChromeDriver
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Properties
;
public
class
SafewayLoginTest
{
}
String
OS
;
String
browser
;
Properties
safewayLoginCreds
;
@Test
public
void
testSafewayLogin
()
throws
InterruptedException
{
setup
();
WebDriver
driver
=
new
ChromeDriver
();
LoginPF
loginPF
=
new
LoginPF
(
driver
);
driver
.
get
(
"https://www.safeway.com/"
);
loginPF
.
login
(
safewayLoginCreds
.
getProperty
(
"username"
),
safewayLoginCreds
.
getProperty
(
"password"
));
Thread
.
sleep
(
10000
);
driver
.
quit
();
}
public
void
setup
()
{
/////////////////////
// Get environment information
/////////////////////
this
.
OS
=
System
.
getProperty
(
"os.name"
);
this
.
browser
=
"Chrome"
;
switch
(
this
.
OS
)
{
case
"Mac OS X"
:
System
.
setProperty
(
"webdriver.chrome.driver"
,
"/Users/kmuldoon/Dev/practice/testing/Selenium/Selenium-POM-Safeway/src/test/resources/chromedriver"
);
break
;
case
"Windows"
:
;
break
;
case
"Linux"
:
;
break
;
default
:
System
.
out
.
println
(
"Unsupported OS"
);
}
System
.
out
.
printf
(
"Running login test using %s on %s\n"
,
browser
,
OS
);
/////////////////////
// Get Login Credentials
/////////////////////
try
(
InputStream
input
=
new
FileInputStream
(
"src/test/resources/credentials.properties"
))
{
this
.
safewayLoginCreds
=
new
Properties
();
// load a properties file
this
.
safewayLoginCreds
.
load
(
input
);
// get the property value and print it out
System
.
out
.
println
(
"username:\t"
+
this
.
safewayLoginCreds
.
getProperty
(
"username"
));
System
.
out
.
println
(
"password:\t"
+
this
.
safewayLoginCreds
.
getProperty
(
"password"
));
}
catch
(
IOException
ex
)
{
ex
.
printStackTrace
();
}
}
}
\ No newline at end of file
src/test/resources/credentials.properties
0 → 100644
View file @
07dedaad
username
=
vkrijegccvsknuvnpv@miucce.com
password
=
12345678
\ No newline at end of file
target/test-classes/SafewayLoginTest.class
View file @
07dedaad
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