creating automation framework code example

Example: creating automation framework

Firstly I would Set up Environment: Install JDK, MAVEN, INTELLIJ IDE
Than I would  Create Maven project
- ArtifactID - name of your project
- GroupID - identifies your project uniquely across all projects
After that I would Add Dependencies from Maven Repository like
- Selenium Java
- Cucumber
- JRE System library 1.8 in <properties>
- TestNG
- WebDriverManager_BoniGarcia
- Cucumber Java
- Cucumber TestNG
- Apache POI.XML
- APACHE POI
- JDBC
- Restassured
- Gson
After Adding all dependencies I would Create framework Structure (packages)
- Pages where I keep webelements and methods
- POJO / Beans
i. Custom classes
- My Runner class has 
i. Cukesrunner - generates codes and stores html report to target
ii. Smoke
iii. Regression
- StepDefinitions has Actual codes and hook class
- Tests is Data driven tests
- JDBC
- API
- I would create Utilities and under utilities I would create
1) ConfigurationReader
2) Driver class (Singleton)
3) browserUtils
4) DBUtils
5) ApiUtils
-I would create Configuration.properties
- Also Testng_runner.xml
-.I would also Create feature folder with feature file in resources
-. After I finish writing your scenario,
run MY cukesRunner with dryRun=true, this will give
you implementation code that you will store in
StepDefinition class

I run my code using runner class - run codes and generate
cucumber report and html reports
8. Send framework to GitHub or SVN
Firstly I would Create new repo
Than Copy git url and go to eclipse
After that I would Configure git repo and add the url
After Right clicking project, click team, click commit and
I’ll be in git staging
 NOW MY CODE IS IN GITHUB
9. Next is JENKINS INTEGRATION
 Jenkins is
1) Open source automation server
2) Helps to automate the non-human part of
the software development process
3) Allows continuous integration
5) Port is 8081 localhost in my company
---To run your project in Jenkins
1) I Login to Jenkins account
2) Create project - freestyle
3) Install plugins -cucumber report and git
4) Under source code management choose
git and past git url
5) Build trigger - choose to build periodically
6) Invoke top-level maven
1. Maven version; MAVEN_HOME
2. Goals; clean verify -
Drunner=smoke_runner.xml
7) Under post-build actions
1. Choose cucumber reports
2. Choose editable email notify
8) Editable email notification
1. Attach build log; choose build log
2. Click advanced settings
9) Failure-Any
1. Click advanced
2. Recipient list - email address who will
receive the report. Add comma if multiple
3. Click add trigger - like failure always
4. Attach build log; select attach build log
5. Save
10) Final Step
1. Click build now and test will run and
gives your cucumber report

Tags:

Misc Example