filmov
tv
5 | Selenium Pytest Examples | Selenium Python
Показать описание
0:00 - Intro
0:43 - Creating a new Python file for the Google search test
1:27 - Importing necessary packages for the test
2:11 - Creating a basic Google search test function
3:47 - Running the test using PyCharm's interface
4:45 - Running the test using the command line
5:45 - Introduction to Pytest fixtures and setup/teardown
6:08 - Creating a Pytest fixture named "driver" for setup and teardown
10:30 - Demonstrating how the fixture works in the test function
11:23 - Using the fixture for setup and teardown of WebDriver
13:10 - Introduction to parameterization with Pytest
13:35 - Creating a parameterized test for a login scenario
15:17 - Running the parameterized test with different sets of data
17:10 - Conclusion & explore more Pytest features
Create a Google Search test with Pytest
Use Pytest fixture for set up and tear down
Use Parameterization with Pytest
Demo & Examples
Step 1 - Create a new python file in project
Step 2 - Import pytest and selenium packages
Step 3 - Create a function and write code for Google Search Test
import pytest
import time
from selenium import webdriver
def test_google_search():
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
print(" Test Completed ")
Step 4 - Run the test from IDE - Rt click > Run pytest… OR from cmd pytest “filename”
Using Pytest Fixtures:
are reusable functions that can be used to set up and tear down test cases
Step 5 - Create a pytest fixture function to setup and teardown driver
Step 6 - Use the fixture in test case
import pytest
import time
from selenium import webdriver
def driver():
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
# Yield the WebDriver instance
yield driver
# Close the WebDriver instance
def test_google_search(driver):
print(" Test Completed ")
Step 7 - Run and check result
Step 8 - Try using parameterization with Pytest
Parametrization is a technique that can be used to run the same test with different values
def driver():
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
# Yield the WebDriver instance
yield driver
# Close the WebDriver instance
("test", "test"),
("user2", "pass2"),
("user3", "pass3"),
])
def test_login(driver, username, password):
Introduction to Selenium Pytest Examples
Test Automation with Selenium and Pytest
Writing Test Cases with Selenium and Pytest
▬▬▬▬▬▬▬
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:43 - Creating a new Python file for the Google search test
1:27 - Importing necessary packages for the test
2:11 - Creating a basic Google search test function
3:47 - Running the test using PyCharm's interface
4:45 - Running the test using the command line
5:45 - Introduction to Pytest fixtures and setup/teardown
6:08 - Creating a Pytest fixture named "driver" for setup and teardown
10:30 - Demonstrating how the fixture works in the test function
11:23 - Using the fixture for setup and teardown of WebDriver
13:10 - Introduction to parameterization with Pytest
13:35 - Creating a parameterized test for a login scenario
15:17 - Running the parameterized test with different sets of data
17:10 - Conclusion & explore more Pytest features
Create a Google Search test with Pytest
Use Pytest fixture for set up and tear down
Use Parameterization with Pytest
Demo & Examples
Step 1 - Create a new python file in project
Step 2 - Import pytest and selenium packages
Step 3 - Create a function and write code for Google Search Test
import pytest
import time
from selenium import webdriver
def test_google_search():
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
print(" Test Completed ")
Step 4 - Run the test from IDE - Rt click > Run pytest… OR from cmd pytest “filename”
Using Pytest Fixtures:
are reusable functions that can be used to set up and tear down test cases
Step 5 - Create a pytest fixture function to setup and teardown driver
Step 6 - Use the fixture in test case
import pytest
import time
from selenium import webdriver
def driver():
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
# Yield the WebDriver instance
yield driver
# Close the WebDriver instance
def test_google_search(driver):
print(" Test Completed ")
Step 7 - Run and check result
Step 8 - Try using parameterization with Pytest
Parametrization is a technique that can be used to run the same test with different values
def driver():
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
# Yield the WebDriver instance
yield driver
# Close the WebDriver instance
("test", "test"),
("user2", "pass2"),
("user3", "pass3"),
])
def test_login(driver, username, password):
Introduction to Selenium Pytest Examples
Test Automation with Selenium and Pytest
Writing Test Cases with Selenium and Pytest
▬▬▬▬▬▬▬
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 ▬▬▬▬
—
Комментарии