WebdriverIO | Page Object Model | Hindi
HTML-код
- Опубликовано: 12 июл 2024
- ALL FREE COURSES ► automationstepbystep.com/
00:00 Intro
01:12 What is Page Object Model
01:45 Sample demo application for testing
04:12 Advantages of POM
05:06 DEMO How to implement POM in WebdriverIO Project
06:12 Sample Login test
14:07 Run demo test
15:50 Check login success message
21:09 Start of Page Object Model Implementation
21:19 Create a class for each page
21:32 Create a new folder and class for Page Objects
22:27 Create object locators in the login page class
25:25 Create methods for actions on the objects
32:07 Refer the class in the test script
37:09 Run POM test
39:34 Outro
#webdriverio #hindi
What is POM
Design pattern to create Object Repository
A class is created for each page to identify web elements of that page
Also contains methods to do action on the objects
Separates test objects and test scripts
Advantages of POM
Makes code maintainable
Changes and updates are easier
Makes code reusable
Improves readability
Single Object Repository
Saves time and efforts
Avoid rework
Makes tests less brittle
New tests creation is easier and faster
Improves Overall quality and efficiency
Demo
How to implement Page Object Model
Step 1 - Create a class for each page
Step 2 - Create locators of all objects to be used in that page
Step 3 - Create methods or actions to be performed on the objects
Step 4 - Refer in the test scripts
Step 5 - Run and validate
class LoginPage
class LoginPage {
get username(){
return $('#username')
}
get password(){
return $('#password')
}
get loginButton(){
return $('button[type="submit"]')
}
get messageBox(){
return $('#flash')
}
async login(username, password){
await this.username.setValue(username)
await this.password.setValue(password)
await this.loginButton.click()
}
async checkLoginMessage(message){
await expect(this.messageBox).toHaveTextContaining(message)
}
}
module.exports = new LoginPage();
Login test
const LoginPage = require('../pageobjects/login.page')
describe('Demo Test', () => {
it('Login Test', async () => {
browser.url('the-internet.herokuapp.com/lo...)
await LoginPage.login('tomsmith', 'SuperSecretPassword!')
await LoginPage.checkLoginMessage('You logged into a secure area!')
})
})
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Every LIKE & SUBSCRIPTION gives me great motivation to keep working for you
You can support my mission for education by sharing this knowledge and helping as many people as you can
If my work has helped you, consider helping any animal near you, in any way you can
NEVER STOP LEARNING
Raghav Pal