0% found this document useful (0 votes)
17 views15 pages

Selenium Hybrid Framework Notes

The document outlines the Selenium Hybrid Framework utilizing Python, Selenium, and PyTest, emphasizing the importance of frameworks for automation in terms of reusability and maintainability. It details various types of frameworks, including Page Object Model, Data Driven Framework, Key-Driven Framework, and Hybrid Driven Framework, along with a step-by-step guide for setting up the framework, executing tests, and integrating with version control and CI/CD tools like Jenkins. Additionally, it provides instructions for generating reports and managing test cases effectively.

Uploaded by

bhushan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views15 pages

Selenium Hybrid Framework Notes

The document outlines the Selenium Hybrid Framework utilizing Python, Selenium, and PyTest, emphasizing the importance of frameworks for automation in terms of reusability and maintainability. It details various types of frameworks, including Page Object Model, Data Driven Framework, Key-Driven Framework, and Hybrid Driven Framework, along with a step-by-step guide for setting up the framework, executing tests, and integrating with version control and CI/CD tools like Jenkins. Additionally, it provides instructions for generating reports and managing test cases effectively.

Uploaded by

bhushan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Selenium Hybrid Framework

(Python, Selenium, PyTest, Page Object Model, HTML Reports)


What is Framework?
Framework is an organized way of maintaining automation files.
In the Framework all the files will communicate each other to perform certain task.
Main Objectives/Goles to use of Framework?
1.Re-usability
2.Maintainability
Types of Frameworks?
1.Built in Frameworks
Pytest, Robot-Framework, Unit-Test etc.
2.Customised/User defined Frameworks
Data driven Framework, Key driven Framework, Hybrid driven Framework.
What is Page Object Model?
Page Object Model also known as POM.
Is a design pattern in selenium that cerate’s an object repository for storing all web-
elements.
It helps reduce code duplication and improves test cases maintenance.
What is Data Driven Framework?
Data driven Framework is used to drive test cases and suites from an external data
feed.
The data feed can be data sheets like excel and csv files.
A data driven framework in selenium is a technique of separating the ‘data sheet’ from
actual test cases
What is Key-Driven Framework?
Is a scripting technique that user data files to contain the keywords related to the
application being tested.
These keywords describe the set of actions that is required to perform specific step.
What is Hybrid driven Framework?
A mix of both the data driven and keyword driven framework.
In this case the keywords as well as the test data are externalized keywords are stored
in a separate python class files and test data can be maintained in a properties file or an
excel files
How to select Test-Cases for the Automation?
Analize application, technology and skill set of teams.
Choose test cases.
Why Automation came in to market? Because overcoming the challenges of re-testing
and regression testing.
If We have 100 test cases then find
How many testcases are to be Re-test cases (Test data)?
How many testcases are Regression cases?
How many testcases -can be automatable?
100% automation? It’s not at all possible there are some test cases we cannot automate
Like Reports, captcha, some activity violence scenarios we cannot automate.

Road map of Framework


1] Analize application, technology and skill set of teams and choose test cases.
2]Design and implementation of framework
3]Execution
4]Maintenance (version control system)
How to generate and install requirement.txt file
Command for generation
pip freeze > requirements.txt
e.g.
pip freeze >.\requirements.txt
command for installation
pip install -r requiorments.txt
e.g.
pip install -r requirements.txt

Step 1: Create new Project & install Required Packages/Plugins


 selenium: For Selenium Libraries
 pytest: For Python UnitTest framework
 pytest-html: For PyTest HTML Reports
 pytest-xdist: To Run Tests Parallel
 openpyxl: For Ms Excel Support
 allure-pytest: To generate allure reports
Step 2: Create Folder Stricture

Project Name
|
pageObjects (Package)
|
TestCases (Package)
|
Utilities (Package)
|
TestData (Folder)
|
Configuration (Folder)
|
Logs (Folder)
|
Screenshots (Folder)
|
Reports (Folder)
|
Run.bat
Step 3: Automating Login Test Cases
1. Create “LoginPage.py” file page object class under “pageObjects” package.

2. Create “Test _Login.py” file under “TestCases”


3. Create “conftest.py” under “TestCases” (common thing we need to separate in
“conftest.py” file using fixture)

Step 4: Capture screenshot on failures


1. Update Login Test with Screenshots folder under “TestCases”
Step 5: Read common values from .ini file (ini file means initialization
file which basically config file where we will keep common data)
2. Add “config.ini” file in “Configurations” folder.

3. Create “readProperties.py” file under “Utilities” package to read common


data.
4. Replace hard coded values in Login test case.

Step 6: Adding logs to test case


1. Add “cousomLogger.py” file under “Utilities” package.
2. Add logs to Login test case.
Step 7: Run Test on Desired Browser/Cross Browser/Parallel
1. Update “conftest.py” with required Fixtures which will accept command
line arguments (browser).

2. Pass browser name as argument in command line


To run tests on desired browser
pytest –s –v testCases/test_login.py --browser chrome
pytest –s –v testCases/test_login.py --browser firefox

To Run tests parallel


pytest –s –v –n=3 testCases/test_login.py –browser chrome
pytest –s –v –n=3 testCases/test_login.py –browser firefox
Step 8: Generate pytest HTML Reports
1. Update confest.py with pytest hooks

2. To Generate HTML report run below command:


pytest –s –v –n=3 --html=reports/report.html
testCases/test_login.py –browser chrome
Step 9: Automating Data Driven Test Case
Prepare test data in Excel sheet page the excel “LoginTestData.xlsx” file inside
the TestData Folder.

Create “XLUtils.py” utilty class under utilities package.


Create “LoginDataDrivenTest.py” under testCases package

Run the test case


Step 10: Adding new test cases
1]Add new customer
2] Search customer by email
3] search customer by name
Step 11: Grouping Tests
1. Grouping markers (Add markers to every test method)
@pytest.mark.sanity
@pytest.mark.regression

2. Add Marker entire in pytest.ini file


Pytest.ini

[pytest]
Markers =
sanity
regression
3. Select groups at run time
-m “sanity”
-m “regression”
-m “sanity and regression”
-m “sanity or regression”
Run Command:
pytest –s –v –m “sanity or regression” –html=./Reports/report.html
testCases/--browser chrome

Step 12: Run Tests in Command Prompt and run.bat file.


1. Create run.bat file
Pytest –s –v –m “sanity” –html=./Reports/report.html testCases/ --browser chrome
2. Open command prompt as Administrator and then run run.bat file
Step 13: Push the code to Git and Git-Hub Repository
1st Round

Initial steps (only one time)


Git init  Create an Empty git repository (Local repository)
git remote add origin (https://github.com------git link-------)
Before doing commit first time we need to execute these bellow commands
git confit –global user.name “----git user name--------”
git confit –global user.email “-----git usermail id---------”
git status
git add –A add all the files in to staging/indexing area
git commit –m “comment”
git push –u origin master
2nd Round

git status
git add –A - add all the files in to staging/indexing area
git commit –m “comment”
git push –u origin master
git pull  pull all the files from github to local
Step 14: Run Test using Jenkins

You might also like