Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
BaitussalamPakistanWebsite
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
Muhammad Rahim Irshad
BaitussalamPakistanWebsite
Commits
5d3dd9ba
Commit
5d3dd9ba
authored
Oct 25, 2022
by
mrahim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bwt web automation
parent
a52e5901
Changes
41
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
41 changed files
with
1062 additions
and
335 deletions
+1062
-335
.gitignore
.gitignore
+0
-38
jpa-buddy.xml
.idea/jpa-buddy.xml
+6
-0
misc.xml
.idea/misc.xml
+3
-0
workspace.xml
.idea/workspace.xml
+110
-67
ReadMe.md
ReadMe.md
+55
-0
pom.xml
pom.xml
+7
-6
Main.java
src/main/java/org/example/Main.java
+0
-7
global.properties
src/main/resources/global.properties
+0
-2
FailedTestRunner.java
src/test/java/com/example/FailedTestRunner.java
+1
-1
TestRunnerPk.java
src/test/java/com/example/TestRunnerPk.java
+5
-3
TestRunnerUsa.java
src/test/java/com/example/TestRunnerUsa.java
+28
-0
BaseClass.java
src/test/java/com/example/Utils/BaseClass.java
+0
-52
AddToCartPage.java
.../java/com/example/pageobjects/pakistan/AddToCartPage.java
+31
-26
BayanatPage.java
...st/java/com/example/pageobjects/pakistan/BayanatPage.java
+12
-2
HomePage.java
src/test/java/com/example/pageobjects/pakistan/HomePage.java
+82
-0
PagesObject.java
...st/java/com/example/pageobjects/pakistan/PagesObject.java
+49
-0
PublicationPage.java
...ava/com/example/pageobjects/pakistan/PublicationPage.java
+7
-5
WelfarePage.java
...st/java/com/example/pageobjects/pakistan/WelfarePage.java
+6
-5
PagesObject.java
src/test/java/com/example/pageobjects/usa/PagesObject.java
+19
-0
WebPage.java
src/test/java/com/example/pageobjects/usa/WebPage.java
+86
-0
AddToCartSteps.java
.../com/example/stepdefinations/pakistan/AddToCartSteps.java
+17
-17
BayanatsPageSteps.java
...m/example/stepdefinations/pakistan/BayanatsPageSteps.java
+4
-4
HomePageSteps.java
...a/com/example/stepdefinations/pakistan/HomePageSteps.java
+69
-8
Hooks.java
...test/java/com/example/stepdefinations/pakistan/Hooks.java
+38
-0
PublicationPageSteps.java
...xample/stepdefinations/pakistan/PublicationPageSteps.java
+7
-8
WelfarePageSteps.java
...om/example/stepdefinations/pakistan/WelfarePageSteps.java
+30
-28
HooksUsa.java
src/test/java/com/example/stepdefinations/usa/HooksUsa.java
+38
-0
WebPageSteps.java
...st/java/com/example/stepdefinations/usa/WebPageSteps.java
+97
-0
DriverManager.java
src/test/java/com/example/utils/DriverManager.java
+87
-0
TextContextSetup.java
src/test/java/com/example/utils/TextContextSetup.java
+19
-0
TextContextSetupUSA.java
src/test/java/com/example/utils/TextContextSetupUSA.java
+19
-0
AddToCart.feature
src/test/java/features/pakistan/AddToCart.feature
+37
-43
BayanatPage.feature
src/test/java/features/pakistan/BayanatPage.feature
+0
-0
EducationPage.feature
src/test/java/features/pakistan/EducationPage.feature
+22
-4
HomePage.feature
src/test/java/features/pakistan/HomePage.feature
+14
-2
PublicationPage.feature
src/test/java/features/pakistan/PublicationPage.feature
+2
-4
WelfarePage.feature
src/test/java/features/pakistan/WelfarePage.feature
+2
-2
USA_Website.feature
src/test/java/features/usa/USA_Website.feature
+49
-0
chromedriver
src/test/resources/chromedriver
+0
-0
global.properties
src/test/resources/global.properties
+3
-0
testng.xml
testng.xml
+1
-1
No files found.
.gitignore
deleted
100644 → 0
View file @
a52e5901
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
\ No newline at end of file
.idea/jpa-buddy.xml
0 → 100644
View file @
5d3dd9ba
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"JpaBuddyIdeaProjectConfig"
>
<option
name=
"renamerInitialized"
value=
"true"
/>
</component>
</project>
\ No newline at end of file
.idea/misc.xml
View file @
5d3dd9ba
...
...
@@ -11,4 +11,7 @@
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_8"
default=
"true"
project-jdk-name=
"azul-1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/out"
/>
</component>
<component
name=
"ProjectType"
>
<option
name=
"id"
value=
"jpab"
/>
</component>
</project>
\ No newline at end of file
.idea/workspace.xml
View file @
5d3dd9ba
This diff is collapsed.
Click to expand it.
ReadMe.md
0 → 100644
View file @
5d3dd9ba
# baitussalam-web-pk-usa
Baitussalam Pakistan and usa Website atuomation
This automation scripts conatains Ui automation of baitussalam Pakistan and Usa
website
# Project structure:
Contains separate pacakages for Pakistan and Usa website work
features/: Gherkin feature files with test scenarios.
hooks/: Cucumber hooks.
runners/: Cucumber test runners.
stepdefinitions/: step definition classes.
transformations/: Cucumber
# Working:
Parallel test runs.
Shared state across cucumber step definitions.
Dependency injection.
Page Object pattern.
Commonly used test utility classes
# Tools:
Maven.
Cucumber-JVM
Testng
Selenium Webdriver
# Notes:
This application contains separate runner classes for Running baitussalam Pakistan
and baitussalam usa Website
# Installation requirement:
This program doesnot require and Installation however need to update the chrome
driver in resources file according to Running system chrome version in resources
file
# Reports:
Cucumber reports will generate in Cucumber-reports under target folder.
\ No newline at end of file
pom.xml
View file @
5d3dd9ba
...
...
@@ -20,12 +20,6 @@
<version>
4.2.2
</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.testng</groupId>-->
<!-- <artifactId>testng</artifactId>-->
<!-- <version>7.6.0</version>-->
<!-- </dependency>-->
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>
org.testng
</groupId>
...
...
@@ -71,6 +65,13 @@
<version>
6.6.6
</version>
<scope>
test
</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-cucumber7-jvm -->
<dependency>
<groupId>
io.qameta.allure
</groupId>
<artifactId>
allure-cucumber7-jvm
</artifactId>
<version>
2.19.0
</version>
</dependency>
</dependencies>
...
...
src/main/java/org/example/Main.java
deleted
100644 → 0
View file @
a52e5901
package
org
.
example
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Hello world!"
);
}
}
\ No newline at end of file
src/main/resources/global.properties
deleted
100644 → 0
View file @
a52e5901
browser
=
Chrome
Url
=
https://dev.baitussalam.org/
\ No newline at end of file
src/test/java/com/example/FailedTestRunner.java
View file @
5d3dd9ba
...
...
@@ -10,7 +10,7 @@ import org.testng.annotations.DataProvider;
"json:target/cucumber-reports/cucumber.json"
},
features
=
{
"@target/failed_scenario.txt"
},
glue
=
{
"com.example.
StepDefinations
"
},
glue
=
{
"com.example.
stepdefinations.pakistan
"
},
monochrome
=
true
,
tags
=
"@web"
)
...
...
src/test/java/com/example/TestRunner.java
→
src/test/java/com/example/TestRunner
Pk
.java
View file @
5d3dd9ba
...
...
@@ -10,13 +10,15 @@ import org.testng.annotations.DataProvider;
"json:target/cucumber-reports/cucumber.json"
,
"rerun:target/failed_scenario.txt"
},
features
=
{
"src/test/
resources/Feature/AddToCart
.feature"
},
glue
=
{
"com.example.
StepDefinations
"
},
features
=
{
"src/test/
java/features/pakistan/HomePage
.feature"
},
glue
=
{
"com.example.
stepdefinations.pakistan
"
},
monochrome
=
true
,
tags
=
"@web"
)
public
class
TestRunner
extends
AbstractTestNGCucumberTests
{
public
class
TestRunnerPk
extends
AbstractTestNGCucumberTests
{
// For parallel execution of test cases
// @Override
// @DataProvider(parallel = true)
...
...
src/test/java/com/example/TestRunnerUsa.java
0 → 100644
View file @
5d3dd9ba
package
com
.
example
;
import
io.cucumber.testng.AbstractTestNGCucumberTests
;
import
io.cucumber.testng.CucumberOptions
;
@CucumberOptions
(
plugin
=
{
"pretty"
,
"html:target/cucumber-reports/cucumber.html"
,
"json:target/cucumber-reports/cucumber.json"
,
"rerun:target/failed_scenario.txt"
},
features
=
{
"src/test/java/features/usa/USA_Website.feature"
},
glue
=
{
"com.example.stepdefinations.usa"
},
monochrome
=
true
,
tags
=
"@web"
)
public
class
TestRunnerUsa
extends
AbstractTestNGCucumberTests
{
// For parallel execution of test cases
// @Override
// @DataProvider(parallel = true)
// public Object [][] scenarios() {
// return super.scenarios();
// }
}
\ No newline at end of file
src/test/java/com/example/Utils/BaseClass.java
deleted
100644 → 0
View file @
a52e5901
package
com
.
example
.
Utils
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.chrome.ChromeDriver
;
import
org.openqa.selenium.firefox.FirefoxDriver
;
import
org.openqa.selenium.logging.LogType
;
import
org.openqa.selenium.logging.LoggingPreferences
;
import
org.openqa.selenium.remote.CapabilityType
;
import
org.openqa.selenium.remote.DesiredCapabilities
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.util.Properties
;
import
java.util.concurrent.TimeUnit
;
import
java.util.logging.Level
;
public
class
BaseClass
{
public
WebDriver
driver
;
public
WebDriver
WebDriverManager
()
throws
IOException
{
FileInputStream
fis
=
new
FileInputStream
(
System
.
getProperty
(
"user.dir"
)+
"//src//main//resources//global.properties"
);
Properties
prop
=
new
Properties
();
prop
.
load
(
fis
);
String
url
=
prop
.
getProperty
(
"Url"
);
String
browser_properties
=
prop
.
getProperty
(
"browser"
);
String
browser_maven
=
System
.
getProperty
(
"browser"
);
String
browser
=
browser_maven
!=
null
?
browser_maven:
browser_properties
;
if
(
driver
==
null
)
{
if
(
browser
.
equalsIgnoreCase
(
"chrome"
))
{
//For chrome browser any other browser can add their
System
.
setProperty
(
"webdriver.chrome.driver"
,
"src/main/resources/chromedriver"
);
DesiredCapabilities
caps
=
new
DesiredCapabilities
();
LoggingPreferences
logPrefs
=
new
LoggingPreferences
();
logPrefs
.
enable
(
LogType
.
BROWSER
,
Level
.
ALL
);
caps
.
setCapability
(
CapabilityType
.
LOGGING_PREFS
,
logPrefs
);
driver
=
new
ChromeDriver
(
caps
);
driver
.
manage
().
timeouts
().
implicitlyWait
(
15
,
TimeUnit
.
SECONDS
);
driver
.
manage
().
window
().
maximize
();
}
// if(browser.equalsIgnoreCase("firefox"))
// {
// System.setProperty("webdriver.gecko.driver", "src/main/resources/geckodriver");
// driver= new FirefoxDriver();
// driver.manage().window().maximize();
// }
driver
.
get
(
url
);
}
return
driver
;
}
}
src/test/java/com/example/
PageObjects
/AddToCartPage.java
→
src/test/java/com/example/
pageobjects/pakistan
/AddToCartPage.java
View file @
5d3dd9ba
package
com
.
example
.
PageObjects
;
package
com
.
example
.
pageobjects
.
pakistan
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.WebElement
;
import
java.util.List
;
import
org.openqa.selenium.support.ui.Select
;
public
class
AddToCartPage
{
public
WebDriver
driver
;
public
AddToCartPage
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
}
public
WebDriver
driver
;
// public List<WebElement> itemsInCartLocator= driver.findElements(By.cssSelector(".box-cart-item h4"));
// public List<WebElement> itemsInCart() {
// return driver.findElements(By.cssSelector(".box-cart-item h4"));
// }
// public void text() {
// driver.findElement(By.cssSelector(".box-cart-item h4"));
// }
public
AddToCartPage
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
}
public
void
closePopup
()
{
driver
.
findElement
(
By
.
xpath
(
"//button[@aria-label='Close']"
)).
click
();
...
...
@@ -32,9 +24,10 @@ public class AddToCartPage {
driver
.
findElement
(
By
.
cssSelector
(
"div:nth-child(3) div:nth-child(3) img:nth-child(1)"
)).
click
();
}
public
void
add
Item
(
)
{
driver
.
findElement
(
By
.
cssSelector
(
"div:nth-child(6) > div:nth-child(2) a:nth-child(3) > p:nth-child(1)"
)).
click
();
public
void
add
ToCartItem
(
String
items
)
{
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//p[normalize-space()='%s']/../../a[2]/p"
,
items
)
)).
click
();
}
public
void
addItem2
()
{
driver
.
findElement
(
By
.
cssSelector
(
"div:nth-child(6) > div:nth-child(5) > div > a:nth-child(3) > p"
)).
click
();
}
...
...
@@ -50,33 +43,45 @@ public class AddToCartPage {
public
WebElement
donationAddedToCart
(
String
text
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//h4[contains(text(),'%s')]"
,
text
)));
}
public
WebElement
donationInCart
(
String
text
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//h4[normalize-space()='%s']"
,
text
)));
}
public
void
closeMessengerPopUp
()
throws
InterruptedException
{
Thread
.
sleep
(
8000
);
driver
.
findElement
(
By
.
cssSelector
(
"#fb-root > div.fb_dialog.fb_dialog_advanced > div > iframe:nth-child(1)"
)).
click
();
driver
.
findElement
(
By
.
cssSelector
(
"#fb-root > div.fb_dialog.fb_dialog_advanced > div > iframe:nth-child(1)"
)).
click
();
}
public
WebElement
removeDonation
(
String
donation
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"(//button[normalize-space()='Remove'])['%s']"
,
donation
)));
public
WebElement
removeDonation
(
String
donation
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"(//button[normalize-space()='Remove'])['%s']"
,
donation
)));
}
public
String
numberOfDonation
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
".modal-body .no-of-cart-items"
)).
getText
().
trim
();
}
public
WebElement
pageHeader
(
String
page
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//h2[normalize-space()='%s']"
,
page
)));
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//h2[normalize-space()='%s']"
,
page
)));
}
public
String
DonationTotalAmountInCart
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"span.cart-amount"
)).
getText
();
}
public
WebElement
amountInCart
(
String
amount
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"(//div[@class='col-xs-5 text-right'][normalize-space()='%s'])"
,
amount
)));
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"(//div[@class='col-xs-5 text-right'][normalize-space()='%s'])"
,
amount
)));
}
public
void
amountAddedForDonationInCart
(
String
amount
)
{
Select
donationAmount
=
new
Select
(
driver
.
findElement
(
By
.
xpath
(
"//select[@name='amount']"
)));
donationAmount
.
selectByVisibleText
(
amount
);
}
// public void jsExecutor(String locator) {
// WebElement element = driver.findElement(By.xpath(String.format("//button[normalize-space()='%s']",locator)));
// Actions actions = new Actions(driver);
// actions.moveToElement(element).click().perform();
// }
public
WebElement
enterAmountForDonationInCart
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"input[id='input_other_amount']"
));
}
}
src/test/java/com/example/
PageObjects
/BayanatPage.java
→
src/test/java/com/example/
pageobjects/pakistan
/BayanatPage.java
View file @
5d3dd9ba
package
com
.
example
.
PageObjects
;
package
com
.
example
.
pageobjects
.
pakistan
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebDriver
;
...
...
@@ -7,32 +7,42 @@ import org.openqa.selenium.WebElement;
public
class
BayanatPage
{
public
WebDriver
driver
;
public
BayanatPage
(
WebDriver
driver
)
{
this
.
driver
=
driver
;}
public
BayanatPage
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
}
public
WebElement
firstNameFieldLocator
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"input[name='first_name']"
));
}
public
WebElement
lastNameFieldLocator
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"input[name='last_name']"
));
}
public
WebElement
emailFieldLocator
()
{
return
driver
.
findElement
(
By
.
xpath
(
"//input[@id='form_email']"
));
}
public
WebElement
phoneFieldLocator
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"input[name='phone']"
));
}
public
WebElement
addressFieldLocator
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"input[name='address']"
));
}
public
WebElement
cityFieldLocator
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"input[name='city']"
));
}
public
WebElement
countryFieldLocator
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"input[name='country']"
));
}
public
WebElement
skillsFieldLocator
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"textarea[name='qualification']"
));
}
public
WebElement
volunteerExperienceFieldLocator
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"textarea[name='experience']"
));
}
...
...
src/test/java/com/example/
PageObjects
/HomePage.java
→
src/test/java/com/example/
pageobjects/pakistan
/HomePage.java
View file @
5d3dd9ba
package
com
.
example
.
PageObjects
;
package
com
.
example
.
pageobjects
.
pakistan
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebDriver
;
...
...
@@ -6,37 +6,77 @@ import org.openqa.selenium.WebElement;
public
class
HomePage
{
public
WebDriver
driver
;
public
HomePage
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
this
.
driver
=
driver
;
}
public
WebElement
aboutUsButtonLocator
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"div.col-sm-3.text-center.box-about > a > img"
));
}
public
WebElement
timeLineButtonLocator
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"div.col-sm-3.text-center.box-timeline > a > img"
));
}
public
WebElement
contactButtonLocator
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"a:nth-child(2) > button"
));
}
public
WebElement
featureLocator
(
Integer
feature
)
{
return
driver
.
findElement
(
By
.
cssSelector
(
"body > div.container-fluid > div > div:nth-child("
+
feature
+
")"
));
return
driver
.
findElement
(
By
.
cssSelector
(
"body > div.container-fluid > div > div:nth-child("
+
feature
+
")"
));
}
public
WebElement
featureLearnMoreButtonLocator
(
String
feature
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//a[@href='https://dev.baitussalam.org/%s']"
,
feature
)));
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//a[@href='https://dev.baitussalam.org/%s']"
,
feature
)));
}
public
WebElement
bayanListLocator
(
String
bayan
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"(//h3[normalize-space()='%s'])"
,
bayan
)));
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"(//h3[normalize-space()='%s'])"
,
bayan
)));
}
public
WebElement
publicationListLocator
(
String
publication
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//span[normalize-space()='%s']"
,
publication
)));
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//span[normalize-space()='%s']"
,
publication
)));
}
public
WebElement
educationProjectListLocator
(
String
educationProject
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//h5[normalize-space()='%s']"
,
educationProject
)));
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//h5[normalize-space()='%s']"
,
educationProject
)));
}
public
WebElement
welfareProjectLocator
(
String
bayan
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"(//h3[normalize-space()='%s'])"
,
bayan
)));
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"(//h3[normalize-space()='%s'])"
,
bayan
)));
}
public
WebElement
emailFieldForSubscription
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"input[name='email']"
));
}
public
WebElement
successMessage
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"div[class='alert alert-success']"
));
}
public
WebElement
socialMediaButton
(
String
socialMedia
)
{
return
driver
.
findElement
(
By
.
cssSelector
(
String
.
format
(
"i[class='fab fa-%s']"
,
socialMedia
)));
}
public
WebElement
contactNameField
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"input[placeholder='Enter Name']"
));
}
public
WebElement
contactEmailField
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"input[placeholder='Enter Email']"
));
}
public
WebElement
contactSubjectField
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"input[placeholder='Enter Subject']"
));
}
public
WebElement
contactPhoneField
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"input[placeholder='Enter Phone']"
));
}
public
WebElement
messageField
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"textarea[placeholder='Enter Message']"
));
}
}
src/test/java/com/example/
PageObjects
/PagesObject.java
→
src/test/java/com/example/
pageobjects/pakistan
/PagesObject.java
View file @
5d3dd9ba
package
com
.
example
.
PageObjects
;
package
com
.
example
.
pageobjects
.
pakistan
;
import
com.example.pageobjects.usa.WebPage
;
import
org.openqa.selenium.WebDriver
;
public
class
PagesObject
{
...
...
@@ -8,35 +9,41 @@ public class PagesObject {
public
HomePage
homePage
;
public
PublicationPage
publicationPage
;
public
BayanatPage
bayanatPage
;
public
WebPage
webPage
;
public
WebDriver
driver
;
public
PagesObject
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
public
PagesObject
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
}
public
AddToCartPage
getAddToCartPage
(){
addToCartPage
=
new
AddToCartPage
(
driver
);
public
AddToCartPage
getAddToCartPage
()
{
addToCartPage
=
new
AddToCartPage
(
driver
);
return
addToCartPage
;
}
public
WelfarePage
getWelfarePage
(){
welfarePage
=
new
WelfarePage
(
driver
);
public
WelfarePage
getWelfarePage
()
{
welfarePage
=
new
WelfarePage
(
driver
);
return
welfarePage
;
}
public
HomePage
getHomePage
(){
homePage
=
new
HomePage
(
driver
);
public
HomePage
getHomePage
()
{
homePage
=
new
HomePage
(
driver
);
return
homePage
;
}
public
PublicationPage
getPublicationPage
(){
publicationPage
=
new
PublicationPage
(
driver
);
public
PublicationPage
getPublicationPage
()
{
publicationPage
=
new
PublicationPage
(
driver
);
return
publicationPage
;
}
public
BayanatPage
getBayanatPage
(){
bayanatPage
=
new
BayanatPage
(
driver
);
public
BayanatPage
getBayanatPage
()
{
bayanatPage
=
new
BayanatPage
(
driver
);
return
bayanatPage
;
}
public
WebPage
getWebPage
()
{
webPage
=
new
WebPage
(
driver
);
return
webPage
;
}
}
src/test/java/com/example/
PageObjects
/PublicationPage.java
→
src/test/java/com/example/
pageobjects/pakistan
/PublicationPage.java
View file @
5d3dd9ba
package
com
.
example
.
PageObjects
;
package
com
.
example
.
pageobjects
.
pakistan
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebDriver
;
...
...
@@ -9,10 +9,12 @@ import org.openqa.selenium.support.ui.Select;
public
class
PublicationPage
{
public
WebDriver
driver
;
public
PublicationPage
(
WebDriver
driver
){
this
.
driver
=
driver
;}
public
PublicationPage
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
}
public
WebElement
pageHeader
(
String
pageHeader
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//a[normalize-space()='%s']"
,
pageHeader
)));
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//a[normalize-space()='%s']"
,
pageHeader
)));
}
public
void
publicationType
(
String
type
)
{
...
...
@@ -25,10 +27,10 @@ public class PublicationPage {
}
public
WebElement
searchButton
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"
.fa.fa-search
"
));
return
driver
.
findElement
(
By
.
cssSelector
(
"
button[class='btn search-button']
"
));
}
public
WebElement
searchFieldLocator
()
{
return
driver
.
findElement
(
By
.
cssSelector
(
"//input[@placeholder='Click to Search']"
));
return
driver
.
findElement
(
By
.
xpath
(
"//input[@placeholder='Click to Search']"
));
}
}
src/test/java/com/example/
PageObjects
/WelfarePage.java
→
src/test/java/com/example/
pageobjects/pakistan
/WelfarePage.java
View file @
5d3dd9ba
package
com
.
example
.
PageObjects
;
package
com
.
example
.
pageobjects
.
pakistan
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebDriver
;
...
...
@@ -207,7 +207,7 @@ public class WelfarePage {
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//label[@for='knowing_someone'][normalize-space()='%s']"
,
radioButton
)));
}
public
String
cnicNumber
(){
public
String
cnicNumber
()
{
BigInteger
maxLimit
=
new
BigInteger
(
"5000000000000"
);
Random
randNum
=
new
Random
();
String
len
=
String
.
valueOf
(
maxLimit
.
bitLength
());
...
...
@@ -215,14 +215,15 @@ public class WelfarePage {
return
res
;
}
public
String
mobileNumber
(){
public
String
mobileNumber
()
{
BigInteger
maxLimit
=
new
BigInteger
(
"500000000"
);
Random
randNum
=
new
Random
();
int
len
=
maxLimit
.
bitLength
();
String
phone
=
"03"
+
new
BigInteger
(
len
,
randNum
);
String
phone
=
"03"
+
new
BigInteger
(
len
,
randNum
);
return
phone
;
}
public
String
phoneNumber
(){
public
String
phoneNumber
()
{
BigInteger
maxLimit
=
new
BigInteger
(
"50000000000"
);
Random
randNum
=
new
Random
();
int
len
=
maxLimit
.
bitLength
();
...
...
src/test/java/com/example/pageobjects/usa/PagesObject.java
0 → 100644
View file @
5d3dd9ba
package
com
.
example
.
pageobjects
.
usa
;
import
org.openqa.selenium.WebDriver
;
public
class
PagesObject
{
public
WebPage
webPage
;
public
WebDriver
driver
;
public
PagesObject
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
}
public
WebPage
getWebPage
(){
webPage
=
new
WebPage
(
driver
);
return
webPage
;
}
}
src/test/java/com/example/pageobjects/usa/WebPage.java
0 → 100644
View file @
5d3dd9ba
package
com
.
example
.
pageobjects
.
usa
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.WebElement
;
import
org.openqa.selenium.interactions.Actions
;
import
org.openqa.selenium.support.ui.Select
;
import
java.util.Iterator
;
import
java.util.Set
;
public
class
WebPage
{
public
WebDriver
driver
;
public
WebPage
(
WebDriver
driver
)
{
this
.
driver
=
driver
;
}
public
By
donationCauseDropDownLocator
=
By
.
cssSelector
(
"#dropdown1"
);
public
By
donationTypeDropDownLocator
=
By
.
cssSelector
(
"#dropdown2"
);
public
By
donationAmountLocator
=
By
.
cssSelector
(
"#dropdown3"
);
public
void
selectDonationCause
(
String
type
)
{
driver
.
findElement
(
donationCauseDropDownLocator
).
click
();
Select
donationCause
=
new
Select
(
driver
.
findElement
(
By
.
cssSelector
(
"#dropdown1"
)));
donationCause
.
selectByVisibleText
(
type
);
}
public
void
selectDonationType
(
String
type
)
{
driver
.
findElement
(
donationTypeDropDownLocator
).
click
();
Select
donationCause
=
new
Select
(
driver
.
findElement
(
By
.
cssSelector
(
"#dropdown2"
)));
donationCause
.
selectByVisibleText
(
type
);
}
public
WebElement
paymentTypes
(
String
payment
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//label[normalize-space()='%s']"
,
payment
)));
}
public
void
clickButton
(
String
buttons
)
{
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//button[normalize-space()='%s']"
,
buttons
))).
click
();
}
public
WebElement
titleButton
(
String
title
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//p[normalize-space()='%s']"
,
title
)));
}
public
WebElement
payPalButton
()
{
return
driver
.
findElement
(
By
.
xpath
(
" //button[@type='submit']"
));
}
public
WebElement
title
(
String
title
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//h2[normalize-space()='%s']"
,
title
)));
}
public
WebElement
contactTitle
(
String
title
)
{
return
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//h3[normalize-space()='%s']"
,
title
)));
}
public
String
payPalTitle
()
{
return
driver
.
findElement
(
By
.
xpath
(
"//h1[normalize-space()='Log in to PayPal']"
)).
getText
();
}
public
void
selectPrograms
(
String
programs
)
{
WebElement
menuOption
=
driver
.
findElement
(
By
.
xpath
(
"//p[normalize-space()='Programs']"
));
Actions
actions
=
new
Actions
(
driver
);
actions
.
moveToElement
(
menuOption
).
perform
();
driver
.
findElement
(
By
.
xpath
(
String
.
format
(
"//p[normalize-space()='%s']"
,
programs
))).
click
();
}
public
String
getCurrentUrl
()
{
String
CurrentUrl
=
driver
.
getCurrentUrl
();
System
.
out
.
println
(
CurrentUrl
);
return
CurrentUrl
;
}
public
void
switchScreen
()
throws
InterruptedException
{
Thread
.
sleep
(
2000
);
Set
<
String
>
s1
=
driver
.
getWindowHandles
();
Iterator
<
String
>
i1
=
s1
.
iterator
();
String
parentWindow
=
i1
.
next
();
String
childWindow
=
i1
.
next
();
driver
.
switchTo
().
window
(
childWindow
);
}
}
src/test/java/com/example/
StepDefinations
/AddToCartSteps.java
→
src/test/java/com/example/
stepdefinations/pakistan
/AddToCartSteps.java
View file @
5d3dd9ba
package
com
.
example
.
StepDefinations
;
package
com
.
example
.
stepdefinations
.
pakistan
;
import
com.example.
PageObjects
.AddToCartPage
;
import
com.example.
U
tils.TextContextSetup
;
import
com.example.
pageobjects.pakistan
.AddToCartPage
;
import
com.example.
u
tils.TextContextSetup
;
import
io.cucumber.datatable.DataTable
;
import
io.cucumber.java.en.And
;
import
io.cucumber.java.en.Then
;
...
...
@@ -41,11 +41,11 @@ public class AddToCartSteps {
addToCartPage
.
donateNowButton
();
}
@When
(
"
^I add 1000-Monthly donation to the cart$
"
)
public
void
iAddItemToCart
()
throws
InterruptedException
{
@When
(
"
I add {string} donation to the cart
"
)
public
void
iAddItemToCart
(
String
addItem
)
throws
InterruptedException
{
AddToCartPage
addToCartPage
=
textContextSetup
.
pagesObject
.
getAddToCartPage
();
Thread
.
sleep
(
2000
);
addToCartPage
.
add
Item
(
);
addToCartPage
.
add
ToCartItem
(
addItem
);
}
@When
(
"^I add donation to the cart$"
)
...
...
@@ -77,16 +77,6 @@ public class AddToCartSteps {
addToCartPage
.
donationAddedToCart
(
donation
).
isDisplayed
();
}
// @When("^I should see the following donation added to the cart$")
// public void iShouldSeeFollowingDonationAddedToCart(DataTable donations) throws Throwable {
// AddToCartPage addToCartPage=textContextSetup.pagesObject.getAddToCartPage();
// Thread.sleep(4000);
// List<Map<String,String>> data = donations.asMaps(String.class,String.class);
// for (Map<String, String> form : data)
// {
//
// }
// }
@When
(
"^I close the messenger popUp$"
)
public
void
messengerPopUp
()
throws
InterruptedException
{
AddToCartPage
addToCartPage
=
textContextSetup
.
pagesObject
.
getAddToCartPage
();
...
...
@@ -141,7 +131,17 @@ public class AddToCartSteps {
addToCartPage
.
amountInCart
(
itemData
.
get
(
"amount"
)).
isDisplayed
();
}
}
}
@Then
(
"I select {string} amount for the donation"
)
public
void
iShouldSelectAmountOfDonation
(
String
amount
)
{
AddToCartPage
addToCartPage
=
textContextSetup
.
pagesObject
.
getAddToCartPage
();
addToCartPage
.
amountAddedForDonationInCart
(
amount
);
}
@Then
(
"I enter amount of {string} for donation"
)
public
void
iShouldEnterAmountOfDonation
(
String
amount
)
{
AddToCartPage
addToCartPage
=
textContextSetup
.
pagesObject
.
getAddToCartPage
();
addToCartPage
.
enterAmountForDonationInCart
().
clear
();
addToCartPage
.
enterAmountForDonationInCart
().
sendKeys
(
amount
);
}
}
src/test/java/com/example/
StepDefinations
/BayanatsPageSteps.java
→
src/test/java/com/example/
stepdefinations/pakistan
/BayanatsPageSteps.java
View file @
5d3dd9ba
package
com
.
example
.
StepDefinations
;
package
com
.
example
.
stepdefinations
.
pakistan
;
import
com.example.
PageObjects
.BayanatPage
;
import
com.example.
U
tils.TextContextSetup
;
import
com.example.
pageobjects.pakistan
.BayanatPage
;
import
com.example.
u
tils.TextContextSetup
;
import
io.cucumber.datatable.DataTable
;
import
io.cucumber.java.en.When
;
import
org.testng.Assert
;
...
...
@@ -74,6 +74,6 @@ public class BayanatsPageSteps {
BayanatPage
bayanatPage
=
textContextSetup
.
pagesObject
.
getBayanatPage
();
String
successMessage
=
bayanatPage
.
successAlertMessageLocator
().
getText
();
System
.
out
.
println
(
successMessage
);
Assert
.
assertEquals
(
successMessage
,
"×\nAlert!\nThank you for applying as a volunteer"
);
Assert
.
assertEquals
(
successMessage
,
"×\nAlert!\nThank you for applying as a volunteer"
);
}
}
src/test/java/com/example/
StepDefinations
/HomePageSteps.java
→
src/test/java/com/example/
stepdefinations/pakistan
/HomePageSteps.java
View file @
5d3dd9ba
package
com
.
example
.
StepDefinations
;
package
com
.
example
.
stepdefinations
.
pakistan
;
import
com.example.
PageObjects
.HomePage
;
import
com.example.
U
tils.TextContextSetup
;
import
com.example.
pageobjects.pakistan
.HomePage
;
import
com.example.
u
tils.TextContextSetup
;
import
io.cucumber.datatable.DataTable
;
import
io.cucumber.java.en.Then
;
import
io.cucumber.java.en.When
;
import
org.openqa.selenium.Keys
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -60,8 +61,8 @@ public class HomePageSteps {
public
void
i_should_see_bayanat_list
(
DataTable
bayanList
)
throws
InterruptedException
{
HomePage
homePage
=
textContextSetup
.
pagesObject
.
getHomePage
();
Thread
.
sleep
(
7000
);
List
<
Map
<
String
,
String
>>
data
=
bayanList
.
asMaps
(
String
.
class
,
String
.
class
);
for
(
Map
<
String
,
String
>
itemData
:
data
){
List
<
Map
<
String
,
String
>>
data
=
bayanList
.
asMaps
(
String
.
class
,
String
.
class
);
for
(
Map
<
String
,
String
>
itemData
:
data
)
{
homePage
.
bayanListLocator
(
itemData
.
get
(
"Bayanat"
)).
isDisplayed
();
}
}
...
...
@@ -70,7 +71,7 @@ public class HomePageSteps {
public
void
i_should_see_publication_list
(
DataTable
bayanList
)
throws
InterruptedException
{
HomePage
homePage
=
textContextSetup
.
pagesObject
.
getHomePage
();
Thread
.
sleep
(
7000
);
List
<
Map
<
String
,
String
>>
data
=
bayanList
.
asMaps
(
String
.
class
,
String
.
class
);
List
<
Map
<
String
,
String
>>
data
=
bayanList
.
asMaps
(
String
.
class
,
String
.
class
);
for
(
Map
<
String
,
String
>
itemData
:
data
)
homePage
.
publicationListLocator
(
itemData
.
get
(
"Publication"
)).
isDisplayed
();
}
...
...
@@ -79,7 +80,7 @@ public class HomePageSteps {
public
void
i_should_see_education_project_list
(
DataTable
bayanList
)
throws
InterruptedException
{
HomePage
homePage
=
textContextSetup
.
pagesObject
.
getHomePage
();
Thread
.
sleep
(
7000
);
List
<
Map
<
String
,
String
>>
data
=
bayanList
.
asMaps
(
String
.
class
,
String
.
class
);
List
<
Map
<
String
,
String
>>
data
=
bayanList
.
asMaps
(
String
.
class
,
String
.
class
);
for
(
Map
<
String
,
String
>
itemData
:
data
)
homePage
.
educationProjectListLocator
(
itemData
.
get
(
"Education"
)).
isDisplayed
();
}
...
...
@@ -88,11 +89,71 @@ public class HomePageSteps {
public
void
i_should_see_welfare_project_list
(
DataTable
bayanList
)
throws
InterruptedException
{
HomePage
homePage
=
textContextSetup
.
pagesObject
.
getHomePage
();
Thread
.
sleep
(
7000
);
List
<
Map
<
String
,
String
>>
data
=
bayanList
.
asMaps
(
String
.
class
,
String
.
class
);
List
<
Map
<
String
,
String
>>
data
=
bayanList
.
asMaps
(
String
.
class
,
String
.
class
);
for
(
Map
<
String
,
String
>
itemData
:
data
)
homePage
.
welfareProjectLocator
(
itemData
.
get
(
"Welfare Project"
)).
isDisplayed
();
}
@Then
(
"I enter email {string} to subscribe 'BAITUSSALAMS NEWSLETTER' on home page"
)
public
void
i_enter_email_text
(
String
email
)
{
HomePage
homePage
=
textContextSetup
.
pagesObject
.
getHomePage
();
homePage
.
emailFieldForSubscription
().
sendKeys
(
email
);
homePage
.
emailFieldForSubscription
().
sendKeys
(
Keys
.
ENTER
);
}
@Then
(
"^I should see the success message$"
)
public
void
i_Should_See_Success_Message
()
throws
InterruptedException
{
HomePage
homePage
=
textContextSetup
.
pagesObject
.
getHomePage
();
Thread
.
sleep
(
3000
);
homePage
.
successMessage
().
isDisplayed
();
String
successMessage
=
homePage
.
successMessage
().
getText
();
System
.
out
.
println
(
"Success alert "
+
successMessage
);
}
@Then
(
"I click on {string} to follow other social media account"
)
public
void
i_Click_Other_Social_Media_Account
(
String
button
)
throws
InterruptedException
{
HomePage
homePage
=
textContextSetup
.
pagesObject
.
getHomePage
();
Thread
.
sleep
(
3000
);
homePage
.
socialMediaButton
(
button
).
click
();
Thread
.
sleep
(
7000
);
}
@When
(
"I fill contact form with following data :"
)
public
void
iFillFromOfOccupationInformation
(
DataTable
formData
)
{
HomePage
homePage
=
textContextSetup
.
pagesObject
.
getHomePage
();
List
<
Map
<
String
,
String
>>
data
=
formData
.
asMaps
(
String
.
class
,
String
.
class
);
for
(
Map
<
String
,
String
>
itemData
:
data
)
{
if
(
itemData
.
containsKey
(
"name"
))
{
homePage
.
contactNameField
().
clear
();
homePage
.
contactNameField
().
sendKeys
(
itemData
.
get
(
"name"
));
}
if
(
itemData
.
containsKey
(
"subject"
))
{
homePage
.
contactSubjectField
().
clear
();
homePage
.
contactSubjectField
().
sendKeys
(
itemData
.
get
(
"subject"
));
}
if
(
itemData
.
containsKey
(
"phone"
))
{
homePage
.
contactPhoneField
().
clear
();
homePage
.
contactPhoneField
().
sendKeys
(
itemData
.
get
(
"phone"
));
}
if
(
itemData
.
containsKey
(
"message"
))
{
homePage
.
messageField
().
clear
();
homePage
.
messageField
().
sendKeys
(
itemData
.
get
(
"message"
));
}
if
(
itemData
.
containsKey
(
"email"
))
{
homePage
.
contactEmailField
().
clear
();
String
[]
arrSplit
=
itemData
.
get
(
"email"
).
split
(
"@"
);
String
emailAddress
=
""
;
while
(
emailAddress
.
length
()
<
5
)
{
emailAddress
+=
arrSplit
[
0
];
emailAddress
+=
Integer
.
valueOf
((
int
)
(
Math
.
random
()
*
99
)).
toString
();
emailAddress
+=
"@"
+
arrSplit
[
1
];
homePage
.
contactEmailField
().
sendKeys
(
emailAddress
);
}
}
}
}
}
src/test/java/com/example/
StepDefinations
/Hooks.java
→
src/test/java/com/example/
stepdefinations/pakistan
/Hooks.java
View file @
5d3dd9ba
package
com
.
example
.
StepDefinations
;
package
com
.
example
.
stepdefinations
.
pakistan
;
import
com.example.PageObjects.AddToCartPage
;
import
com.example.Utils.TextContextSetup
;
import
com.example.utils.TextContextSetup
;
import
io.cucumber.java.After
;
import
io.cucumber.java.AfterStep
;
import
io.cucumber.java.BeforeStep
;
import
io.cucumber.java.Scenario
;
import
org.apache.commons.io.FileUtils
;
import
org.openqa.selenium.OutputType
;
...
...
@@ -16,24 +14,25 @@ import java.io.IOException;
public
class
Hooks
{
TextContextSetup
textContextSetup
;
public
Hooks
(
TextContextSetup
textContextSetup
){
this
.
textContextSetup
=
textContextSetup
;
}
public
Hooks
(
TextContextSetup
textContextSetup
)
{
this
.
textContextSetup
=
textContextSetup
;
}
@After
public
void
closingDriver
()
throws
IOException
{
textContextSetup
.
baseClass
.
WebDriverManager
().
quit
();
}
textContextSetup
.
driverManager
.
WebDriverManager
().
quit
();
}
@AfterStep
public
void
addScreenShot
(
Scenario
scenario
)
throws
IOException
{
WebDriver
driver
=
textContextSetup
.
baseClass
.
WebDriverManager
();
if
(
scenario
.
isFailed
())
{
File
sourcePath
=((
TakesScreenshot
)
driver
).
getScreenshotAs
(
OutputType
.
FILE
);
byte
[]
fileContent
=
FileUtils
.
readFileToByteArray
(
sourcePath
);
scenario
.
attach
(
fileContent
,
"image/png"
,
"Error image"
);
}
WebDriver
driver
=
textContextSetup
.
driverManager
.
WebDriverManager
();
if
(
scenario
.
isFailed
())
{
File
sourcePath
=
((
TakesScreenshot
)
driver
).
getScreenshotAs
(
OutputType
.
FILE
);
byte
[]
fileContent
=
FileUtils
.
readFileToByteArray
(
sourcePath
);
scenario
.
attach
(
fileContent
,
"image/png"
,
"Error image"
);
}
}
}
src/test/java/com/example/
StepDefinations
/PublicationPageSteps.java
→
src/test/java/com/example/
stepdefinations/pakistan
/PublicationPageSteps.java
View file @
5d3dd9ba
package
com
.
example
.
StepDefinations
;
package
com
.
example
.
stepdefinations
.
pakistan
;
import
com.example.
PageObjects
.PublicationPage
;
import
com.example.
U
tils.TextContextSetup
;
import
com.example.
pageobjects.pakistan
.PublicationPage
;
import
com.example.
u
tils.TextContextSetup
;
import
io.cucumber.java.en.When
;
public
class
PublicationPageSteps
{
...
...
@@ -14,26 +14,25 @@ public class PublicationPageSteps {
@When
(
"I select header {string} on publication page"
)
public
void
iShouldSelectItemFromDropDownHeaderTitle
(
String
header
)
throws
InterruptedException
{
PublicationPage
publicationPage
=
textContextSetup
.
pagesObject
.
getPublicationPage
();
Thread
.
sleep
(
300
);
Thread
.
sleep
(
300
);
publicationPage
.
pageHeader
(
header
).
click
();
}
@When
(
"I select {string} Publication Type on Subscribe for our publications on publication page"
)
public
void
iShouldSelectPublicationType
(
String
publicationType
)
throws
InterruptedException
{
PublicationPage
publicationPage
=
textContextSetup
.
pagesObject
.
getPublicationPage
();
Thread
.
sleep
(
300
);
Thread
.
sleep
(
300
);
publicationPage
.
publicationType
(
publicationType
);
}
@When
(
"I enter email {string} on Subscribe for our publication modal"
)
public
void
iEnterEmailOnSubscribeForPublicationModal
(
String
email
)
throws
InterruptedException
{
public
void
iEnterEmailOnSubscribeForPublicationModal
(
String
email
)
{
PublicationPage
publicationPage
=
textContextSetup
.
pagesObject
.
getPublicationPage
();
Thread
.
sleep
(
300
);
publicationPage
.
email
().
sendKeys
(
email
);
}
@When
(
"I enter {string} in Search field in order to search on publication page"
)
public
void
iSearchFromSearchBoxForPublicationPage
(
String
searchItem
){
public
void
iSearchFromSearchBoxForPublicationPage
(
String
searchItem
)
{
PublicationPage
publicationPage
=
textContextSetup
.
pagesObject
.
getPublicationPage
();
publicationPage
.
searchFieldLocator
().
sendKeys
(
searchItem
);
publicationPage
.
searchButton
().
click
();
...
...
src/test/java/com/example/
StepDefinations
/WelfarePageSteps.java
→
src/test/java/com/example/
stepdefinations/pakistan
/WelfarePageSteps.java
View file @
5d3dd9ba
package
com
.
example
.
StepDefinations
;
package
com
.
example
.
stepdefinations
.
pakistan
;
import
com.example.
PageObjects
.PublicationPage
;
import
com.example.
PageObjects
.WelfarePage
;
import
com.example.
U
tils.TextContextSetup
;
import
com.example.
pageobjects.pakistan
.PublicationPage
;
import
com.example.
pageobjects.pakistan
.WelfarePage
;
import
com.example.
u
tils.TextContextSetup
;
import
io.cucumber.datatable.DataTable
;
import
io.cucumber.java.en.Given
;
import
io.cucumber.java.en.When
;
import
org.openqa.selenium.support.ui.Select
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
public
class
WelfarePageSteps
{
...
...
@@ -118,24 +118,25 @@ public class WelfarePageSteps {
}
}
if
(
itemData
.
containsKey
(
"phoneNumber"
))
{
if
(
itemData
.
get
(
"phoneNumber"
).
equalsIgnoreCase
(
"random"
))
{
welfarePage
.
phoneFieldLocator
().
clear
();
String
phoneNumber
=
welfarePage
.
phoneNumber
();
welfarePage
.
phoneFieldLocator
().
sendKeys
(
phoneNumber
);
}
else
{
if
(
itemData
.
get
(
"phoneNumber"
).
equalsIgnoreCase
(
"random"
))
{
welfarePage
.
phoneFieldLocator
().
clear
();
String
phoneNumber
=
welfarePage
.
phoneNumber
();
welfarePage
.
phoneFieldLocator
().
sendKeys
(
phoneNumber
);
}
else
{
welfarePage
.
phoneFieldLocator
().
clear
();
welfarePage
.
phoneFieldLocator
().
sendKeys
(
itemData
.
get
(
"phoneNumber"
));
}}
}
}
if
(
itemData
.
containsKey
(
"CNIC"
))
{
if
(
itemData
.
get
(
"CNIC"
).
equalsIgnoreCase
(
"random"
))
{
if
(
itemData
.
get
(
"CNIC"
).
equalsIgnoreCase
(
"random"
))
{
welfarePage
.
cnicFieldLocator
().
clear
();
String
cnicNumber
=
welfarePage
.
cnicNumber
();
String
cnicNumber
=
welfarePage
.
cnicNumber
();
welfarePage
.
cnicFieldLocator
().
sendKeys
(
cnicNumber
);
}
else
{
welfarePage
.
cnicFieldLocator
().
clear
();
welfarePage
.
cnicFieldLocator
().
sendKeys
(
itemData
.
get
(
"CNIC"
));
}
else
{
welfarePage
.
cnicFieldLocator
().
clear
();
welfarePage
.
cnicFieldLocator
().
sendKeys
(
itemData
.
get
(
"CNIC"
));
}}
}
if
(
itemData
.
containsKey
(
"address"
))
{
welfarePage
.
addressFieldLocator
().
clear
();
welfarePage
.
addressFieldLocator
().
sendKeys
(
itemData
.
get
(
"address"
));
...
...
@@ -240,15 +241,16 @@ public class WelfarePageSteps {
List
<
Map
<
String
,
String
>>
data
=
formData
.
asMaps
(
String
.
class
,
String
.
class
);
for
(
Map
<
String
,
String
>
itemData
:
data
)
{
if
(
itemData
.
containsKey
(
"workExperience"
))
{
if
((
itemData
.
get
(
"workExperience"
)).
equalsIgnoreCase
(
"Yes"
))
{
welfarePage
.
volunteerExperienceRadioButton
(
itemData
.
get
(
"workExperience"
)).
click
();
}}
if
(
itemData
.
containsKey
(
"workExperienceDetail"
)){
if
(
itemData
.
get
(
"workExperience"
).
equalsIgnoreCase
(
"Yes"
)
){
welfarePage
.
volunteerExperienceDescription
().
sendKeys
(
itemData
.
get
(
"workExperienceDetail"
));
}}
if
(
itemData
.
containsKey
(
"workExperience"
))
{
if
((
itemData
.
get
(
"workExperience"
)).
equalsIgnoreCase
(
"Yes"
))
{
welfarePage
.
volunteerExperienceRadioButton
(
itemData
.
get
(
"workExperience"
)).
click
();
}
}
if
(
itemData
.
containsKey
(
"workExperienceDetail"
))
{
if
(
itemData
.
get
(
"workExperience"
).
equalsIgnoreCase
(
"Yes"
))
{
welfarePage
.
volunteerExperienceDescription
().
sendKeys
(
itemData
.
get
(
"workExperienceDetail"
));
}
}
if
(
itemData
.
containsKey
(
"startWorkingDate"
))
{
welfarePage
.
workStartDate
().
clear
();
welfarePage
.
workStartDate
().
sendKeys
(
itemData
.
get
(
"startWorkingDate"
));
...
...
@@ -268,8 +270,8 @@ public class WelfarePageSteps {
welfarePage
.
monthsAvailability
(
itemData
.
get
(
"monthlyAvailability"
)).
click
();
}
if
(
itemData
.
containsKey
(
"dayAvailability"
))
{
String
arr
[]
=
itemData
.
get
(
"dayAvailability"
).
split
(
","
);
welfarePage
.
daysAvailability
(
arr
[
0
],
arr
[
1
]).
click
();
String
arr
[]
=
itemData
.
get
(
"dayAvailability"
).
split
(
","
);
welfarePage
.
daysAvailability
(
arr
[
0
],
arr
[
1
]).
click
();
}
if
(
itemData
.
containsKey
(
"reasonForWorking"
))
{
welfarePage
.
reasonToWork
().
sendKeys
(
itemData
.
get
(
"reasonForWorking"
));
...
...
src/test/java/com/example/stepdefinations/usa/HooksUsa.java
0 → 100644
View file @
5d3dd9ba
package
com
.
example
.
stepdefinations
.
usa
;
import
com.example.utils.TextContextSetupUSA
;
import
io.cucumber.java.After
;
import
io.cucumber.java.AfterStep
;
import
io.cucumber.java.Scenario
;
import
org.apache.commons.io.FileUtils
;
import
org.openqa.selenium.OutputType
;
import
org.openqa.selenium.TakesScreenshot
;
import
org.openqa.selenium.WebDriver
;
import
java.io.File
;
import
java.io.IOException
;
public
class
HooksUsa
{
TextContextSetupUSA
textContextSetup
;
public
HooksUsa
(
TextContextSetupUSA
textContextSetup
)
{
this
.
textContextSetup
=
textContextSetup
;
}
@After
public
void
closingDriver
()
throws
IOException
{
textContextSetup
.
driverManager
.
WebDriverManagerUsa
().
quit
();
}
@AfterStep
public
void
addScreenShot
(
Scenario
scenario
)
throws
IOException
{
WebDriver
driver
=
textContextSetup
.
driverManager
.
WebDriverManager
();
if
(
scenario
.
isFailed
())
{
File
sourcePath
=
((
TakesScreenshot
)
driver
).
getScreenshotAs
(
OutputType
.
FILE
);
byte
[]
fileContent
=
FileUtils
.
readFileToByteArray
(
sourcePath
);
scenario
.
attach
(
fileContent
,
"image/png"
,
"Error image"
);
}
}
}
src/test/java/com/example/stepdefinations/usa/WebPageSteps.java
0 → 100644
View file @
5d3dd9ba
package
com
.
example
.
stepdefinations
.
usa
;
import
com.example.pageobjects.usa.WebPage
;
import
com.example.utils.TextContextSetupUSA
;
import
io.cucumber.java.en.Then
;
import
io.cucumber.java.en.When
;
import
org.testng.Assert
;
public
class
WebPageSteps
{
TextContextSetupUSA
textContextSetup
;
public
WebPageSteps
(
TextContextSetupUSA
textContextSetup
)
{
this
.
textContextSetup
=
textContextSetup
;
}
@When
(
"I select donation {string} cause in 'Donation now modal' on Home page"
)
public
void
iSelectDonationCause
(
String
type
)
{
WebPage
webPage
=
textContextSetup
.
pagesObject
.
getWebPage
();
webPage
.
selectDonationCause
(
type
);
}
@When
(
"I select donation {string} type in 'Donation now modal' on Home page"
)
public
void
iSelectDonationType
(
String
type
)
{
WebPage
webPage
=
textContextSetup
.
pagesObject
.
getWebPage
();
webPage
.
selectDonationType
(
type
);
}
@When
(
"I select {string} payment type"
)
public
void
iSelectPayment
(
String
paymentType
)
{
WebPage
webPage
=
textContextSetup
.
pagesObject
.
getWebPage
();
webPage
.
paymentTypes
(
paymentType
).
click
();
}
@When
(
"^I press paypal button$"
)
public
void
iPressButton
()
throws
InterruptedException
{
WebPage
webPage
=
textContextSetup
.
pagesObject
.
getWebPage
();
Thread
.
sleep
(
1000
);
webPage
.
payPalButton
().
click
();
Thread
.
sleep
(
7000
);
}
@When
(
"I Enter Donation {string} amount"
)
public
void
iEnterDonationAmount
(
String
amount
)
{
WebPage
webPage
=
textContextSetup
.
pagesObject
.
getWebPage
();
webPage
.
driver
.
findElement
(
webPage
.
donationAmountLocator
).
sendKeys
(
amount
);
}
@When
(
"I press {string} title button on home page"
)
public
void
iPressTitleButton
(
String
button
)
{
WebPage
webPage
=
textContextSetup
.
pagesObject
.
getWebPage
();
webPage
.
titleButton
(
button
).
click
();
}
@Then
(
"I should see tile button is redirected to {string}"
)
public
void
iShouldSee
(
String
title
)
{
WebPage
webPage
=
textContextSetup
.
pagesObject
.
getWebPage
();
webPage
.
title
(
title
).
isDisplayed
();
}
@Then
(
"I should see tile button is redirected to contacts {string}"
)
public
void
iShouldSeeContactsInformation
(
String
title
)
{
WebPage
webPage
=
textContextSetup
.
pagesObject
.
getWebPage
();
webPage
.
contactTitle
(
title
).
isDisplayed
();
}
@When
(
"I hover on program and select the {string} program"
)
public
void
iSelectPrograms
(
String
title
)
{
WebPage
webPage
=
textContextSetup
.
pagesObject
.
getWebPage
();
webPage
.
selectPrograms
(
title
);
}
@When
(
"I click on {string} button"
)
public
void
iClickOnButton
(
String
button
)
{
WebPage
webPage
=
textContextSetup
.
pagesObject
.
getWebPage
();
webPage
.
clickButton
(
button
);
}
@When
(
"User redirected to correct website {string}"
)
public
void
iRedirectedToWebsite
(
String
websiteUrl
)
{
WebPage
webPage
=
textContextSetup
.
pagesObject
.
getWebPage
();
String
currentUrl
=
webPage
.
getCurrentUrl
();
Assert
.
assertEquals
(
websiteUrl
,
currentUrl
);
}
@When
(
"User landed on paypal {string} page"
)
public
void
iRedirectedToPaypal
(
String
paypalTitle
)
throws
InterruptedException
{
WebPage
webPage
=
textContextSetup
.
pagesObject
.
getWebPage
();
webPage
.
switchScreen
();
String
pageTitle
=
webPage
.
payPalTitle
();
System
.
out
.
println
(
pageTitle
);
Assert
.
assertEquals
(
paypalTitle
,
pageTitle
);
}
}
src/test/java/com/example/utils/DriverManager.java
0 → 100644
View file @
5d3dd9ba
package
com
.
example
.
utils
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.chrome.ChromeDriver
;
import
org.openqa.selenium.logging.LogType
;
import
org.openqa.selenium.logging.LoggingPreferences
;
import
org.openqa.selenium.remote.CapabilityType
;
import
org.openqa.selenium.remote.DesiredCapabilities
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.util.Properties
;
import
java.util.concurrent.TimeUnit
;
import
java.util.logging.Level
;
public
class
DriverManager
{
public
WebDriver
driver
;
public
WebDriver
WebDriverManager
()
throws
IOException
{
FileInputStream
fis
=
new
FileInputStream
(
System
.
getProperty
(
"user.dir"
)
+
"//src//test//resources//global.properties"
);
Properties
prop
=
new
Properties
();
prop
.
load
(
fis
);
String
urlPk
=
prop
.
getProperty
(
"UrlPk"
);
String
browser_properties
=
prop
.
getProperty
(
"browser"
);
String
browser_maven
=
System
.
getProperty
(
"browser"
);
String
browser
=
browser_maven
!=
null
?
browser_maven
:
browser_properties
;
if
(
driver
==
null
)
{
//Todo: For chrome browser any other browser can add their
if
(
browser
.
equalsIgnoreCase
(
"chrome"
))
{
System
.
setProperty
(
"webdriver.chrome.driver"
,
"src/test/resources/chromedriver"
);
DesiredCapabilities
caps
=
new
DesiredCapabilities
();
LoggingPreferences
logPrefs
=
new
LoggingPreferences
();
logPrefs
.
enable
(
LogType
.
BROWSER
,
Level
.
ALL
);
caps
.
setCapability
(
CapabilityType
.
LOGGING_PREFS
,
logPrefs
);
driver
=
new
ChromeDriver
(
caps
);
driver
.
manage
().
timeouts
().
implicitlyWait
(
15
,
TimeUnit
.
SECONDS
);
driver
.
manage
().
window
().
maximize
();
}
//Todo: Fire fox work will be included
// if(browser.equalsIgnoreCase("firefox"))
// {
// System.setProperty("webdriver.gecko.driver", "src/test/resources/geckodriver");
// driver= new FirefoxDriver();
// driver.manage().window().maximize();
// }
driver
.
get
(
urlPk
);
}
return
driver
;
}
public
WebDriver
WebDriverManagerUsa
()
throws
IOException
{
FileInputStream
fis
=
new
FileInputStream
(
System
.
getProperty
(
"user.dir"
)
+
"//src//test//resources//global.properties"
);
Properties
prop
=
new
Properties
();
prop
.
load
(
fis
);
String
urlPk
=
prop
.
getProperty
(
"UrlUsa"
);
String
browser_properties
=
prop
.
getProperty
(
"browser"
);
String
browser_maven
=
System
.
getProperty
(
"browser"
);
String
browser
=
browser_maven
!=
null
?
browser_maven
:
browser_properties
;
if
(
driver
==
null
)
{
if
(
browser
.
equalsIgnoreCase
(
"chrome"
))
{
//For chrome browser any other browser can add their
System
.
setProperty
(
"webdriver.chrome.driver"
,
"src/test/resources/chromedriver"
);
DesiredCapabilities
caps
=
new
DesiredCapabilities
();
LoggingPreferences
logPrefs
=
new
LoggingPreferences
();
logPrefs
.
enable
(
LogType
.
BROWSER
,
Level
.
ALL
);
caps
.
setCapability
(
CapabilityType
.
LOGGING_PREFS
,
logPrefs
);
driver
=
new
ChromeDriver
(
caps
);
driver
.
manage
().
timeouts
().
implicitlyWait
(
15
,
TimeUnit
.
SECONDS
);
driver
.
manage
().
window
().
maximize
();
}
//Todo: Fire fox work will be included
// if(browser.equalsIgnoreCase("firefox"))
// {
// System.setProperty("webdriver.gecko.driver", "src/test/resources/geckodriver");
// driver= new FirefoxDriver();
// driver.manage().window().maximize();
// }
driver
.
get
(
urlPk
);
}
return
driver
;
}
}
src/test/java/com/example/
U
tils/TextContextSetup.java
→
src/test/java/com/example/
u
tils/TextContextSetup.java
View file @
5d3dd9ba
package
com
.
example
.
U
tils
;
package
com
.
example
.
u
tils
;
import
com.example.
PageObjects
.PagesObject
;
import
com.example.
pageobjects.pakistan
.PagesObject
;
import
org.openqa.selenium.WebDriver
;
import
java.io.IOException
;
...
...
@@ -8,9 +8,12 @@ import java.io.IOException;
public
class
TextContextSetup
{
public
WebDriver
driver
;
public
PagesObject
pagesObject
;
public
BaseClass
baseClass
;
public
DriverManager
driverManager
;
public
TextContextSetup
()
throws
IOException
{
baseClass
=
new
BaseClass
();
pagesObject
=
new
PagesObject
(
baseClass
.
WebDriverManager
());
driverManager
=
new
DriverManager
();
pagesObject
=
new
PagesObject
(
driverManager
.
WebDriverManager
());
}
}
src/test/java/com/example/utils/TextContextSetupUSA.java
0 → 100644
View file @
5d3dd9ba
package
com
.
example
.
utils
;
import
com.example.pageobjects.pakistan.PagesObject
;
import
org.openqa.selenium.WebDriver
;
import
java.io.IOException
;
public
class
TextContextSetupUSA
{
public
WebDriver
driver
;
public
PagesObject
pagesObject
;
public
DriverManager
driverManager
;
public
TextContextSetupUSA
()
throws
IOException
{
driverManager
=
new
DriverManager
();
pagesObject
=
new
PagesObject
(
driverManager
.
WebDriverManagerUsa
());
}
}
src/test/
resources/Feature
/AddToCart.feature
→
src/test/
java/features/pakistan
/AddToCart.feature
View file @
5d3dd9ba
...
...
@@ -8,7 +8,7 @@ Feature: Add_To_Cart
@web
Scenario
:
To verify 1000-Monthly donation for One-time added to the cart
When
I add
1000-Monthly
donation to the cart
When
I add
"1000 - Monthly"
donation to the cart
And
I select
"One Time"
payment
And
I press
"Add Donation"
Then
I should see
"1000 - Monthly"
is added to the cart
...
...
@@ -16,7 +16,7 @@ Feature: Add_To_Cart
@web
Scenario
:
To verify 1000-Monthly donation on Recurring Weekly basis is added to the cart
When
I add
1000-Monthly
donation to the cart
When
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Weekly"
payment
And
I press
"Add Donation"
...
...
@@ -24,8 +24,8 @@ Feature: Add_To_Cart
@web
Scenario
:
To verify 1000-Monthly donation on Recurring
Monthly basis is added to the cart
When
I add
1000-Monthly
donation to the cart
Scenario
:
To verify 1000-Monthly donation on Recurring Monthly basis is added to the cart
When
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I press
"Add Donation"
...
...
@@ -34,7 +34,7 @@ Feature: Add_To_Cart
@web
Scenario
:
To verify 1000-Monthly donation on Recurring Yearly basis is added to the cart
When
I add
1000-Monthly
donation to the cart
When
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Yearly"
payment
And
I press
"Add Donation"
...
...
@@ -42,12 +42,12 @@ Feature: Add_To_Cart
@web
Scenario
:
To verify multiple donation of 1000-Monthly monthly added to cart
When
I add
1000-Monthly
donation to the cart
When
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I press
"Add Donation"
When
I press
"Add Another"
And
I add
1000-Monthly
donation to the cart
And
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Yearly"
payment
And
I press
"Add Donation"
...
...
@@ -58,17 +58,17 @@ Feature: Add_To_Cart
@web
Scenario
:
Verify user shouldn't see removed listed donation to the cart when add new donation to cart
When
I add
1000-Monthly
donation to the cart
When
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I press
"Add Donation"
When
I press
"Add Another"
And
I add
1000-Monthly
donation to the cart
And
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Yearly"
payment
And
I press
"Add Donation"
When
I press
"Add Another"
And
I add
1000-Monthly
donation to the cart
And
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I press
"Add Donation"
...
...
@@ -79,14 +79,15 @@ Feature: Add_To_Cart
|
1000
-
Monthly
|
When
I remove
"1"
Donation to the cart
When
I press
"Add Another"
And
I add
1000-Monthly
donation to the cart
And
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I press
"Add Donation"
Then
I should see You are donating to
"3"
cause
# <------ After remove of any donation Use see removed listed donation in the cart-------->
Scenario
:
To check checkout button is clickable and user is redirected to checkout page
When
I add
1000-Monthly
donation to the cart
When
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I press
"Add Donation"
...
...
@@ -95,17 +96,17 @@ Feature: Add_To_Cart
@web
Scenario
:
User Should be able to see correct number of donation after removing donation to cart list
When
I add
1000-Monthly
donation to the cart
When
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I press
"Add Donation"
When
I press
"Add Another"
And
I add
1000-Monthly
donation to the cart
And
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Yearly"
payment
And
I press
"Add Donation"
When
I press
"Add Another"
And
I add
1000-Monthly
donation to the cart
And
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I press
"Add Donation"
...
...
@@ -114,57 +115,36 @@ Feature: Add_To_Cart
@web
Scenario
:
User should see correct amount of added donation in the cart
When
I add
1000-Monthly
donation to the cart
When
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I press
"Add Donation"
When
I press
"Add Another"
And
I add
1000-Monthly
donation to the cart
And
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Yearly"
payment
And
I press
"Add Donation"
When
I press
"Add Another"
And
I add
1000-Monthly
donation to the cart
And
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I press
"Add Donation"
Then
I should see total amount Rs"3000" on add to cart module
@web
Scenario
:
User Should be able to see correct number of donation after removing donation to cart list
When
I add 1000-Monthly donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I press
"Add Donation"
When
I press
"Add Another"
And
I add 1000-Monthly donation to the cart
And
I select
"Recurring"
payment
And
I select
"Yearly"
payment
And
I press
"Add Donation"
When
I press
"Add Another"
And
I add 1000-Monthly donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I press
"Add Donation"
Then
I should see the following donation detail added to the cart
|
title
|
amount
|
|
1000
-
Monthly
|
1000
|
|
1000
-
Monthly
|
1000
|
|
1000
-
Monthly
|
1000
|
@web
Scenario
:
User should
not be able to remove all the donation of 1000-Monthly Recurring donation to cart when remove the first donation to cart lis
t
When
I add
1000-Monthly
donation to the cart
Scenario
:
User should
be redirected to checkout page after adding donation to car
t
When
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I press
"Add Donation"
When
I press
"Add Another"
And
I add donation to the cart
And
I add
"Baitussalam Nusrat Roti Pack - Syria - Sadqa"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Yearly"
payment
And
I press
"Add Donation"
When
I press
"Add Another"
And
I add
1000-Monthly
donation to the cart
And
I add
"1000 - Monthly"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I press
"Add Donation"
...
...
@@ -176,3 +156,17 @@ Feature: Add_To_Cart
When
I press
"Checkout"
Then
User should be redirected to
"Checkout"
page
@web
Scenario
:
User should be redirected to checkout page after adding donation to cart in which user able to enter amount of donation
When
I add
"Sadaqah - Water"
donation to the cart
And
I select
"Recurring"
payment
And
I select
"Monthly"
payment
And
I select
"Other Amount"
amount for the donation
And
I enter amount of
"100"
for donation
And
I press
"Add Donation"
Then
I should see the following donation detail added to the cart
|
title
|
amount
|
|
Sadaqah
-
Water
|
Rs.
100
|
When
I press
"Checkout"
Then
User should be redirected to
"Checkout"
page
\ No newline at end of file
src/test/
resources/Feature
/BayanatPage.feature
→
src/test/
java/features/pakistan
/BayanatPage.feature
View file @
5d3dd9ba
File moved
src/test/
resources/Feature
/EducationPage.feature
→
src/test/
java/features/pakistan
/EducationPage.feature
View file @
5d3dd9ba
...
...
@@ -6,7 +6,7 @@ Feature: Education_Page
@web
Scenario Outline
:
User should be redirected to correct pages when Selecting Projects from drop down
Scenario Outline
:
User should be redirected to correct pages when Selecting Projects from drop down
On Education Page
When
I select a
"education"
feature on home page
And
I should hover on
"Projects"
welfare header title to select
"<headerItems>"
item from drop down on welfare page
Then
User should be redirected to
"<pages>"
page
...
...
@@ -17,7 +17,7 @@ Feature: Education_Page
@web
Scenario Outline
:
User should be redirected to correct pages when Selecting Events from drop down
Scenario Outline
:
User should be redirected to correct pages when Selecting Events from drop down
On Education Page
When
I select a
"education"
feature on home page
And
I should hover on
"Events"
welfare header title to select
"<headerItems>"
item from drop down on welfare page
Then
User should be redirected to
"<pages>"
page
...
...
@@ -28,7 +28,7 @@ Feature: Education_Page
@web
Scenario Outline
:
User should be redirected to correct pages when Selecting News from drop down
Scenario Outline
:
User should be redirected to correct pages when Selecting News from drop down
On Education Page
When
I select a
"education"
feature on home page
And
I should hover on
"News"
welfare header title to select
"<headerItems>"
item from drop down on welfare page
Then
User should be redirected to
"<pages>"
page
...
...
@@ -41,7 +41,7 @@ Feature: Education_Page
|
Abdülhamit
School
|
Abdülhamit
School
|
@web
Scenario Outline
:
User should be redirected to correct pages when Selecting Media from drop down
Scenario Outline
:
User should be redirected to correct pages when Selecting Media from drop down
On Education Page
When
I select a
"education"
feature on home page
And
I should hover on
"Media"
welfare header title to select
"<headerItems>"
item from drop down on welfare page
Then
User should be redirected to
"<pages>"
page
...
...
@@ -50,3 +50,21 @@ Feature: Education_Page
|
headerItems
|
pages
|
|
Images
|
Gallery
|
|
Videos
|
Gallery
|
@web
Scenario
:
User should be redirected to correct pages when Selecting About Us On Education Page
When
I select a
"education"
feature on home page
When
I click on
"About us"
button on welfare page
Then
User should be redirected to
"About us"
page
@web
Scenario
:
User should be redirected to correct pages when Selecting Contact Us On Education Page
When
I select a
"education"
feature on home page
When
I click on
"Contact"
button on welfare page
Then
User should be redirected to
"Contact"
page
@web
Scenario
:
User should be redirected to correct pages when Selecting Contribute On Education Page
When
I select a
"education"
feature on home page
When
I click on
"Contribute"
button on welfare page
Then
User should be redirected to
"Ways to Donate"
page
src/test/
resources/Feature
/HomePage.feature
→
src/test/
java/features/pakistan
/HomePage.feature
View file @
5d3dd9ba
...
...
@@ -6,10 +6,14 @@ Feature: HomePage
@web
Scenario
:
User should be redirected to About Us
,TimeLine pages
Scenario
:
User should be redirected to About Us
When
I Click on About Us button on Home page
And
Close the popup
Then
User should be redirected to
"About us"
page
@web
Scenario
:
User should be redirected to TimeLine pages
When
I Click On Our Timeline Button On home page
And
Close the popup
Then
User should be redirected to
"Timeline"
page
...
...
@@ -19,7 +23,11 @@ Feature: HomePage
Scenario
:
User should be redirected to Contact page
When
I Click On Our contact Button On home page
Then
User should be redirected to
"Contact"
page
When I fill contact form with following data
:
|
name
|
email
|
subject
|
phone
|
message
|
|
testing
|
abc@123.com
|
software
engineer
|
031232131231231
|
testing
a
web
app
|
And
I press
"Send your message"
# <-------- Bug after click on Send your message button -------->
@web
Scenario
:
User should be redirected to bayanat page
...
...
@@ -64,5 +72,9 @@ Feature: HomePage
|
RELIEF
FOR
BEIRUT
|
@web
Scenario
:
User should be able to subscribe 'BAITUSSALAM NEWSLETTER'
When
I enter email
"abc@123.com"
to subscribe 'BAITUSSALAMS NEWSLETTER' on home page
Then
I should see the success message
src/test/
resources/Feature
/PublicationPage.feature
→
src/test/
java/features/pakistan
/PublicationPage.feature
View file @
5d3dd9ba
...
...
@@ -6,7 +6,7 @@ Feature: Publication Feature
@web
Scenario Outline
:
User should be able redirecting to correct pages by selecting header from publication page
Scenario Outline
:
User should be able redirecting to correct pages by selecting header from publication page
When
I select a
"publication"
feature on home page
And
I select header
"<headerItems>"
on publication page
Then
User should be redirected to
"<pages>"
page
...
...
@@ -22,7 +22,6 @@ Feature: Publication Feature
|
Booklets
by
Maulana
Adbul
Sattar
|
Booklets
by
Maulana
Adbul
Sattar
|
@web
Scenario
:
User should be able to subscribe for publication
When
I select a
"publication"
feature on home page
...
...
@@ -30,13 +29,12 @@ Feature: Publication Feature
And
I select
"Bulletin"
Publication Type on Subscribe for our publications on publication page
And
I enter email
"abc@abc.com"
on Subscribe for our publication modal
And
I press
"Subscribe Now"
# <-------- Bug "Subscribe now button" is not working ------>
# <-------- Bug "Subscribe now button" is not working
after click its start loading not redirect to any page
------>
@web
Scenario
:
User should be able to search for publication
When
I select a
"publication"
feature on home page
And
I select header
"Subscribe Now"
on publication page
And
I enter
"Intellect Magazine"
in Search field in order to search on publication page
Then
User should be redirected to
"Results for Intellect Magazine"
page
# <------ Bug Always directed to search page even if page is not present(return empty page) -------->
src/test/
resources/Feature
/WelfarePage.feature
→
src/test/
java/features/pakistan
/WelfarePage.feature
View file @
5d3dd9ba
...
...
@@ -101,12 +101,12 @@ Feature: Welfare Feature
Then
User should be redirected to
"Ways to Donate"
page
@web
Scenario
:
User should be able to become a volunteer
Scenario
:
User should be able to become a volunteer
on welfare Page
When
I select a
"welfare"
feature on home page
When
I click on
"Join Us"
button on welfare page
And I fill Volunteer information in the Become a Volunteer form with the following data on welfare Page
:
|
fullName
|
DateOfBirth
|
email
|
phoneNumber
|
address
|
city
|
country
|
CNIC
|
mobileNumber
|
postalCode
|
|
Muhammad
rahim
|
2000-10-03
|
test@123gmail.com
|
random
|
karachi
|
xyz
street
|
Pakistan
|
random
|
random
|
12313
|
|
Muhammad
rahim
|
2000-10-03
|
test@123gmail.com
|
random
|
karachi
|
xyz
street
|
Pakistan
|
random
|
random
|
12313
|
And I fill alternate contact information in the Become a Volunteer form with the following data on welfare Page
:
|
alternateFullName
|
relation
|
alternatePhoneNumber
|
alternateAddress
|
alternateCity
|
alternateCountry
|
alternateMobileNumber
|
alternatePostalCode
|
education
|
|
Muhammad
rahim
|
Friend
|
12323123
|
abc
street
|
karachi
|
Pakistan
|
0312313141414
|
42233
|
Graduation
|
...
...
src/test/java/features/usa/USA_Website.feature
0 → 100644
View file @
5d3dd9ba
Feature
:
Add donation
@web
Scenario Outline
:
User should be able to make a donation
When
I select
"One Time"
payment type
And
I select donation
"<cause>"
cause in 'Donation now modal' on Home page
And
I select donation
"<type>"
type in 'Donation now modal' on Home page
And
I Enter Donation
"200"
amount
And
I press paypal button
Then
User landed on paypal
"Log in to PayPal"
page
Examples
:
|
cause
|
type
|
|
General
|
SADAQAH
|
|
General
|
ZAKAT
|
|
General
|
ATYAAT
|
|
General
|
AQEEQA
|
|
General
|
WAQF
|
|
General
|
BRANCH_ONLINE
|
|
Monthly
Scholarship
|
ZAKAT
|
|
Construction
of
Schools
|
ATYAAT
|
|
Monthly
USD$50
Food
Basket
|
WAQF
|
|
Monthly
Scholarship
|
SADAQAH
|
|
Monthly
Kafalat
Program
|
WAQF
|
|
Construction
of
Schools
|
ZAKAT
|
|
Construction
of
Saiban
|
WAQF
|
@web
Scenario
:
User should be correctly redirected by clicking on header buttons
When
I press
"About Us"
title button on home page
Then
I should see tile button is redirected to
"About Baitussalam USA"
When
I press
"Programs"
title button on home page
Then
I should see tile button is redirected to
"Projects & Programs"
When
I press
"Programs"
title button on home page
Then
I should see tile button is redirected to contacts
"Quick Connect"
@web
Scenario
:
User should be see to selected programs
When
I hover on program and select the
"Monthly Food Basket Distribution Program"
program
Then
I should see tile button is redirected to
"Monthly Food Basket Distribution Program"
When
I hover on program and select the
"Eid-ul-Adha Qurbani (Waqf) Program"
program
Then
I should see tile button is redirected to
"Eid-ul-Adha Qurbani (Waqf) Program"
@web
Scenario
:
User should be redirected to Baitussalam Pakistan by clicking on Our Partner button
When
I click on
"Our Partner"
button
Then User redirected to correct website "https
:
//www.baitussalam.org/"
src/
main
/resources/chromedriver
→
src/
test
/resources/chromedriver
View file @
5d3dd9ba
File moved
src/test/resources/global.properties
0 → 100644
View file @
5d3dd9ba
browser
=
Chrome
UrlPk
=
https://dev.baitussalam.org/
UrlUsa
=
https://dev.baitussalamusa.org/
\ No newline at end of file
testng.xml
View file @
5d3dd9ba
...
...
@@ -3,7 +3,7 @@
<suite
name=
"Test Suite"
verbose=
"1"
>
<test
name=
"Regression Tests"
>
<classes>
<class
name=
"com.example.TestRunner"
>
<class
name=
"com.example.TestRunner
Pk
"
>
</class>
</classes>
</test>
...
...
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