create framework from scratch code example
Example: create framework from scratch
1. Set up Environment:
Install JDK, MAVEN, INTELLIJ IDE
2. Create Maven project
● ArtifactID - name of your project
● GroupID - identifies your project uniquely across
all projects
3. Add Dependencies from Maven Repository
● Selenium Java
● Cucumber Sandwich
● JRE System library 1.8 in <properties>
● TestNG
● WebDriverManager_BoniGarcia● Cucumber Java
● Cucumber TestNG
● Apache POI.XML
● APACHE POI
● JDBC
● Restassured
● Gson
● Log4j
4. Create framework Structure (packages)
● Pages
i. Webelements and methods
● POJO / Beans
i. Custom classes
● Runner
i. Cuckesrunner - generates codes and stores
html report to target
ii. Smoke
iii. Regression
● StepDefinitions
i. Actual codes and hook class
● Tests
i. Data driven tests
● JDBC
● API
● Utilities1) ConfigurationReader
2) Driver class (Singleton)
3) browserUtils
4) DBUtils
5) ApiUtils
● Configuration.properties
● Testng_runner.xml
1. One of the runner class Call the packages
with com.app.utilities
5. Create feature folder with feature file
(.feature) in resources
● File executable specification written in a gherkin
language
6. After you finish writing your scenario,
run your cukesRunner with dryRun=true, this will give
you implementation code that you will store in
StepDefinition class
7. How to run your code?
● Use runner class - run codes and generate
cucumber report and html reports
8. Send framework to GitHub or SVN
● Create new repo
● Copy git url and go to eclipse
● Configure git repo and add the url
● Right click project, click team, click commit and
you’ll be in git staging● NOW YOUR CODE IS IN GITHUB
9. Next is JENKINS INTEGRATION
● Jenkins
1) Open source automation server
2) Helps to automate the non-human part of
the software development process
3) Allows continuous integration
4) Development practice that requires dev to
integrate code into a shared repo at reg intervals
5) Port is 8081 localhost