filmov
tv
6 | Page Object Model | Selenium Python
![preview_player](https://i.ytimg.com/vi/0kHbK5iZkN0/maxresdefault.jpg)
Показать описание
0:00 - Introduction and session overview.
0:33 - Explanation of what the Page Object Model (POM) is.
1:43 - Benefits of using the Page Object Model, separating locators and actions.
3:25 - Creating folders for pages and tests in the project.
4:46 - Creating a Python file for the LoginTest.
5:32 - Creating a Python file for the LoginPage class.
9:10 - Creating a constructor in the LoginPage class to accept the driver instance.
12:08 - Defining locators for username, password, and login button.
14:20 - Defining methods for actions like opening the page, entering username and password, and clicking the login button.
24:38 - Importing the LoginPage class in the test script.
25:10 - Creating an instance of the LoginPage class and performing actions using the defined methods
Page Object Model
What is POM - Page Object Model
How to implement POM in Selenium Python Project
Demo and Hands-On
Step 1 - In the project folder create 2 folders pages and tests
Step 4 - In the class LoginPage create a constructor function that takes driver parameter
Step 5 - In the constructor function add locators for all elements of login page as needed for the test
Step 6 - Create functions for login actions
Step 8 - Create an object for LoginPage class to access the functions of the class
Step 9 - Replace the test scripts with LoginPage function calls
Step 10 - Run and test
import pytest
import time
from selenium import webdriver
def driver():
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
yield driver
def test_login(driver):
login_page = LoginPage(driver)
class LoginPage:
def __init__(self, driver):
def open_page(self, url):
def enter_username(self, username):
def enter_password(self, password):
def click_login(self):
▬▬▬▬▬▬▬
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
▬▬▬▬ USEFUL LINKS ▬▬▬▬
---
0:33 - Explanation of what the Page Object Model (POM) is.
1:43 - Benefits of using the Page Object Model, separating locators and actions.
3:25 - Creating folders for pages and tests in the project.
4:46 - Creating a Python file for the LoginTest.
5:32 - Creating a Python file for the LoginPage class.
9:10 - Creating a constructor in the LoginPage class to accept the driver instance.
12:08 - Defining locators for username, password, and login button.
14:20 - Defining methods for actions like opening the page, entering username and password, and clicking the login button.
24:38 - Importing the LoginPage class in the test script.
25:10 - Creating an instance of the LoginPage class and performing actions using the defined methods
Page Object Model
What is POM - Page Object Model
How to implement POM in Selenium Python Project
Demo and Hands-On
Step 1 - In the project folder create 2 folders pages and tests
Step 4 - In the class LoginPage create a constructor function that takes driver parameter
Step 5 - In the constructor function add locators for all elements of login page as needed for the test
Step 6 - Create functions for login actions
Step 8 - Create an object for LoginPage class to access the functions of the class
Step 9 - Replace the test scripts with LoginPage function calls
Step 10 - Run and test
import pytest
import time
from selenium import webdriver
def driver():
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
yield driver
def test_login(driver):
login_page = LoginPage(driver)
class LoginPage:
def __init__(self, driver):
def open_page(self, url):
def enter_username(self, username):
def enter_password(self, password):
def click_login(self):
▬▬▬▬▬▬▬
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
▬▬▬▬ USEFUL LINKS ▬▬▬▬
---
Комментарии