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
61f0fef1
Commit
61f0fef1
authored
Apr 13, 2021
by
Shaphen Pangburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Account Settings to not rely on instantiating new instances of the HomePage class
parent
0cbbb44c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
AccountSettingsPage.java
...um/pompagefactory/practice/pages/AccountSettingsPage.java
+9
-6
HomePage.java
...ava/com/nisum/pompagefactory/practice/pages/HomePage.java
+0
-2
No files found.
src/main/java/com/nisum/pompagefactory/practice/pages/AccountSettingsPage.java
View file @
61f0fef1
package
com
.
nisum
.
pompagefactory
.
practice
.
pages
;
package
com
.
nisum
.
pompagefactory
.
practice
.
pages
;
import
com.nisum.pompagefactory.practice.pages.HomePage
;
import
com.nisum.pompagefactory.practice.pages.HomePage
;
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.FindBy
;
import
org.openqa.selenium.support.FindBy
;
...
@@ -27,16 +28,18 @@ public class AccountSettingsPage {
...
@@ -27,16 +28,18 @@ public class AccountSettingsPage {
PageFactory
.
initElements
(
this
.
driver
,
this
);
PageFactory
.
initElements
(
this
.
driver
,
this
);
}
}
public
WebElement
getAccountDropdown
()
{
return
driver
.
findElement
(
By
.
linkText
(
"Account"
));
}
public
WebElement
getAccountSettingsButton
()
{
return
driver
.
findElement
(
By
.
xpath
(
"//*[@id=\"menu\"]/div[1]/ul/li[4]/a"
));
}
public
void
goToAccountSettings
()
{
public
void
goToAccountSettings
()
{
WebDriverWait
wait
=
new
WebDriverWait
(
driver
,
5
);
WebDriverWait
wait
=
new
WebDriverWait
(
driver
,
5
);
// setup
// click account dropdown menu
HomePage
home
=
new
HomePage
(
driver
,
"https://www.safeway.com/"
,
false
);
wait
.
until
(
ExpectedConditions
.
elementToBeClickable
(
getAccountDropdown
()));
wait
.
until
(
ExpectedConditions
.
elementToBeClickable
(
home
.
getAccountDropdown
()));
getAccountDropdown
().
click
();
home
.
getAccountDropdown
().
click
();
// click account settings button
// click account settings button
wait
.
until
(
ExpectedConditions
.
elementToBeClickable
(
home
.
getAccountSettingsButton
()));
wait
.
until
(
ExpectedConditions
.
elementToBeClickable
(
getAccountSettingsButton
()));
home
.
getAccountSettingsButton
().
click
();
getAccountSettingsButton
().
click
();
}
}
}
}
src/main/java/com/nisum/pompagefactory/practice/pages/HomePage.java
View file @
61f0fef1
...
@@ -19,8 +19,6 @@ public class HomePage {
...
@@ -19,8 +19,6 @@ public class HomePage {
public
WebElement
getMenuNav
()
{
return
driver
.
findElement
(
By
.
linkText
(
"Sign In / Up"
));
}
public
WebElement
getMenuNav
()
{
return
driver
.
findElement
(
By
.
linkText
(
"Sign In / Up"
));
}
public
WebElement
getSignInButton
()
{
return
driver
.
findElement
(
By
.
id
(
"sign-in-modal-link"
));
}
public
WebElement
getSignInButton
()
{
return
driver
.
findElement
(
By
.
id
(
"sign-in-modal-link"
));
}
public
WebElement
getAccountDropdown
()
{
return
driver
.
findElement
(
By
.
linkText
(
"Account"
));
}
public
WebElement
getAccountSettingsButton
()
{
return
driver
.
findElement
(
By
.
xpath
(
"//*[@id=\"menu\"]/div[1]/ul/li[4]/a"
));
}
public
void
navigateToLogin
()
{
public
void
navigateToLogin
()
{
WebDriverWait
wait
=
new
WebDriverWait
(
driver
,
5
);
WebDriverWait
wait
=
new
WebDriverWait
(
driver
,
5
);
...
...
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