Framework Mode - First Selenium script
Folder Structure
selenium_project/ ├── tests/ │ └── test_first_script.py ├── pages/ │ └── home_page.py ├── utils/ │ └── driver_factory.py ├── config/ │ └── config.yaml └── requirements.txt
selenium_project/ ├── tests/ │ └── test_first_script.py ├── pages/ │ └── home_page.py ├── utils/ │ └── driver_factory.py ├── config/ │ └── config.yaml └── requirements.txt
driver_factory.py).home_page.py).test_first_script.py).config.yaml).Use a config.yaml file to store environment details such as:
Load this config in your driver factory and tests to keep code flexible and avoid hardcoding.
pytest with pytest-html plugin to generate readable HTML reports.Where would you add a new page object for the Login page in this framework structure?
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get('https://example.com')
element = driver.find_element(By.TAG_NAME, 'h1')
print(element.text)
driver.quit()from selenium import webdriver
driver = webdriver.Chrome
driver.get('https://example.com')
driver.quit()Pass the test and this pattern moves unknown