Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
awa-w7d2-selenium-pageobjectpattern
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
Eric Arndt
awa-w7d2-selenium-pageobjectpattern
Commits
70128f0b
Commit
70128f0b
authored
Apr 14, 2021
by
earndt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[W7D2] (ArndtED) Adds login page web-driving
parent
9f2a2173
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
21 deletions
+88
-21
GetConfigProperties.java
selenium-assignment/src/main/java/GetConfigProperties.java
+47
-0
Login.java
selenium-assignment/src/main/java/Login.java
+25
-14
SafewayTestApp.java
selenium-assignment/src/main/java/SafewayTestApp.java
+16
-0
SafewayTest.java
selenium-assignment/src/test/java/SafewayTest.java
+0
-7
No files found.
selenium-assignment/src/main/java/GetConfigProperties.java
0 → 100644
View file @
70128f0b
//import java.io.FileNotFoundException;
//import java.io.IOException;
//import java.io.InputStream;
//import java.util.Date;
//import java.util.Properties;
//
// /**
// * @author Crunchify.com
// *
// */
//
// public class GetConfigProperties {
// String result = "";
// InputStream inputStream;
//
// public String getPropValues() throws IOException {
//
// try {
// Properties prop = new Properties();
// String propFileName = "config.properties";
//
// inputStream = getClass().getClassLoader().getResourceAsStream(propFileName);
//
// if (inputStream != null) {
// prop.load(inputStream);
// } else {
// throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
// }
//
// Date time = new Date(System.currentTimeMillis());
//
// // get the property value and print it out
// String user = prop.getProperty("user");
// String company1 = prop.getProperty("company1");
// String company2 = prop.getProperty("company2");
// String company3 = prop.getProperty("company3");
//
// result = "Company List = " + company1 + ", " + company2 + ", " + company3;
// System.out.println(result + "\nProgram Ran on " + time + " by user=" + user);
// } catch (Exception e) {
// System.out.println("Exception: " + e);
// } finally {
// inputStream.close();
// }
// return result;
// }
// }
selenium-assignment/src/main/java/Login.java
View file @
70128f0b
import
org.openqa.selenium.By
;
import
org.openqa.selenium.By
;
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.ui.ExpectedConditions
;
import
org.openqa.selenium.support.ui.WebDriverWait
;
import
java.util.concurrent.TimeUnit
;
public
class
Login
{
public
class
Login
{
WebDriver
driver
;
WebDriver
driver
;
WebElement
linkSignIn
;
WebElement
inputUsername
;
WebElement
inputPassword
;
WebElement
buttonSubmit
;
public
Login
(
WebDriver
driver
){
public
Login
(
WebDriver
driver
){
this
.
driver
=
driver
;
this
.
driver
=
driver
;
driver
.
manage
().
timeouts
().
implicitlyWait
(
3
,
TimeUnit
.
SECONDS
);
}
public
WebElement
getFirstSignInButton
(){
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"
));
}
}
public
WebElement
get
LinkSignI
n
(){
public
WebElement
get
SecondSignInButto
n
(){
return
driver
.
findElement
(
By
.
xpath
(
"/
/a[text()='Login']"
));
//figure out string
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/div/div[2]/div[1]/div[1]/div[1]/a"
));
}
}
public
WebElement
getInput
Username
(){
public
WebElement
getInput
Email
(){
return
driver
.
findElement
(
By
.
xpath
(
"/
/input[@name='username']"
));
//figure out string
return
driver
.
findElement
(
By
.
xpath
(
"/
html/body/div[1]/div/div/div[3]/div/div/div/div[1]/div[2]/div[2]/div/div/div/div/div[2]/div/div/div[2]/form/div[1]/input"
));
}
}
public
WebElement
getInputPassword
(){
public
WebElement
getInputPassword
(){
return
driver
.
findElement
(
By
.
name
(
"password"
));
//figure out string
return
driver
.
findElement
(
By
.
xpath
(
"/html/body/div[1]/div/div/div[3]/div/div/div/div[1]/div[2]/div[2]/div/div/div/div/div[2]/div/div/div[2]/form/div[2]/div/input"
));
}
}
public
WebElement
get
ButtonSubmit
(){
public
WebElement
get
FinalSignInButton
(){
return
driver
.
findElement
(
By
.
name
(
"Submit"
));
//figure out string
return
driver
.
findElement
(
By
.
xpath
(
"/html/body/div[1]/div/div/div[3]/div/div/div/div[1]/div[2]/div[2]/div/div/div/div/div[2]/div/div/div[2]/form/div[5]/div[1]/input"
));
}
}
public
void
navigateHome
(
String
url
){
public
void
navigateHome
(
String
url
){
driver
.
get
(
url
);
driver
.
get
(
url
);
}
}
public
void
login
(
String
username
,
String
password
){
public
void
login
(
String
email
,
String
password
){
getInputUsername
().
sendKeys
(
username
);
getFirstSignInButton
().
click
();
getSecondSignInButton
().
click
();
getInputEmail
().
sendKeys
(
email
);
getInputPassword
().
sendKeys
(
password
);
getInputPassword
().
sendKeys
(
password
);
getButtonSubmit
().
click
();
WebDriverWait
wdw
=
new
WebDriverWait
(
driver
,
5
);
wdw
.
until
(
ExpectedConditions
.
elementToBeClickable
(
getFinalSignInButton
()));
getFinalSignInButton
().
click
();
}
}
}
}
selenium-assignment/src/main/java/SafewayTestApp.java
0 → 100644
View file @
70128f0b
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.chrome.ChromeDriver
;
public
class
SafewayTestApp
{
public
static
void
main
(
String
[]
args
)
{
final
String
email
=
"vkrijegccvsknuvnpv@miucce.com"
;
final
String
password
=
"12345678"
;
final
String
website
=
"https://safeway.com"
;
System
.
setProperty
(
"webdriver.chrome.driver"
,
"/Users/earndt/Desktop/NNDNN/selenium-test-assignment/src/test/resources/chromedriver"
);
WebDriver
driver
=
new
ChromeDriver
();
Login
login
=
new
Login
(
driver
);
login
.
navigateHome
(
website
);
login
.
login
(
email
,
password
);
}
}
selenium-assignment/src/test/java/SafewayTest.java
View file @
70128f0b
...
@@ -3,12 +3,5 @@ import org.openqa.selenium.WebDriver;
...
@@ -3,12 +3,5 @@ import org.openqa.selenium.WebDriver;
import
org.openqa.selenium.chrome.ChromeDriver
;
import
org.openqa.selenium.chrome.ChromeDriver
;
public
class
SafewayTest
{
public
class
SafewayTest
{
@Test
public
void
testSafewayCredentials
()
throws
Exception
{
System
.
setProperty
(
"webdriver.chrome.driver"
,
"/Users/earndt/Desktop/NNDNN/selenium-test-assignment/src/test/resources/chromedriver"
)
}
WebDriver
driver
=
new
ChromeDriver
();
Login
login
=
new
Login
(
driver
);
}
}
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