The Page Object Model (POM) keeps Selenium locators and page-specific actions in Python classes, while tests describe scenarios and assert the results. Give each page or meaningful reusable UI component an object, pass it the WebDriver, and use condition-based waits when the page updates asynchronously.
What the Page Object Model does
A page object is an interface between a test and a page or UI area. It owns the locators and useful operations for that area; the test uses those operations to carry out a scenario. For example, a login test can call login_as() instead of repeating username, password, and submit selectors in every test.
This separation reduces duplicated UI code: when markup changes, you can often update the locator or interaction in one place. Selenium describes page objects as models of areas of an application’s UI and recommends keeping verifications in test code, not in page objects. See the Selenium Page Object Models guide.
Set up a small Python project
Install Selenium in your project environment:
python -m pip install selenium
Recent Selenium versions can manage supported browser drivers through Selenium Manager. If your environment requires a separately installed driver, make sure it is compatible with the browser you intend to run. The example below uses Chrome and a demonstration URL; replace the URL and selectors with those from your application.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
project/
pages/
__init__.py
login_page.py
test_login.py
Create a page object
Put the login form’s locators and interactions in pages/login_page.py. This example waits until the form is visible before entering credentials, then waits for a post-login heading to appear. Change the selectors and expected text to match your site.
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
class LoginPage:
URL = "https://example.com/login"
USERNAME = (By.ID, "username")
PASSWORD = (By.ID, "password")
SUBMIT = (By.CSS_SELECTOR, "button[type='submit']")
DASHBOARD_HEADING = (By.CSS_SELECTOR, "h1")
def __init__(self, driver):
self.driver = driver
self.wait = WebDriverWait(driver, 10)
def open(self):
self.driver.get(self.URL)
self.wait.until(EC.visibility_of_element_located(self.USERNAME))
return self
def login_as(self, username, password):
self.wait.until(EC.visibility_of_element_located(self.USERNAME)).send_keys(username)
self.driver.find_element(*self.PASSWORD).send_keys(password)
self.wait.until(EC.element_to_be_clickable(self.SUBMIT)).click()
return DashboardPage(self.driver)
class DashboardPage:
DASHBOARD_HEADING = (By.CSS_SELECTOR, "h1")
def __init__(self, driver):
self.driver = driver
self.wait = WebDriverWait(driver, 10)
def heading_text(self):
heading = self.wait.until(
EC.visibility_of_element_located(self.DASHBOARD_HEADING)
)
return heading.text
The By locator tuples make the locator strategy and value explicit. Selenium supports ID, name, CSS selector, link text, partial link text, class name, tag name, and XPath; choose a locator that is clear and stable for your application’s markup. Prefer test-specific attributes when your team provides them. See the Selenium locator strategies reference.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Write the test and keep assertions there
A test creates the browser, runs the user-level operation, and verifies the expected outcome. Save this as test_login.py; set credentials through environment variables or your test configuration rather than committing real secrets.
import os
from selenium import webdriver
from pages.login_page import LoginPage
def test_login_shows_dashboard():
driver = webdriver.Chrome()
try:
dashboard = LoginPage(driver).open().login_as(
os.environ["TEST_USERNAME"],
os.environ["TEST_PASSWORD"],
)
assert dashboard.heading_text() == "Dashboard"
finally:
driver.quit()
The equality assertion belongs in the test because it expresses the expected behavior. A page object may perform a narrow readiness check when opening a page, but avoid hiding ordinary test expectations inside its methods. Selenium’s Python bindings Page Objects tutorial shows a similar page-object and test flow; its particular folder and locator-class arrangement is one possible organization, not a required framework.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Wait for the condition the next action needs
A navigation call returning does not guarantee that JavaScript-rendered controls are ready. Use WebDriverWait(driver, timeout).until(condition) for the needed state, such as presence, visibility, or clickability. In the example, the form must be visible before typing and the submit button clickable before clicking.
- Presence: the element exists in the DOM, but may not be visible.
- Visibility: the element exists and is displayed.
- Clickability: the element is visible and enabled for interaction.
Fixed sleeps delay every run regardless of readiness and can still be too short when the application is slow. Selenium’s Waiting Strategies guide explains how asynchronous changes can cause race conditions and flaky tests. Keep a consistent wait policy; Selenium cautions that mixing implicit and explicit waits can produce unpredictable timing behavior.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Choose page and component boundaries
Use one object per meaningful page
A page class should group locators and operations that belong to that page, such as searching, submitting a form, or reading a visible status. Give methods names that describe user tasks rather than merely wrapping a low-level call like find_element().
Extract repeated regions when they have behavior
If a navigation bar, product card, or other coherent region appears on multiple pages and has meaningful operations, model it as a component object and compose it into the relevant page objects. This keeps repeated behavior in one place. Avoid making classes for trivial fragments that add indirection without reuse.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Keep locator organization understandable
For a small project, locator tuples can live directly on their page class. A separate locator class or module can help when it improves readability, but it is not a requirement. The key is to keep knowledge of a page’s structure close to the code that uses it rather than scattering selectors across tests.
Common problems and fixes
- Element not found: confirm the locator matches the current page, that the page has loaded the relevant content, and that the element is not inside an iframe. Wait for an appropriate condition before locating or interacting with dynamic content.
- Click intercepted or element not clickable: wait for clickability and check whether an overlay, animation, or consent dialog covers the control. Do not treat a fixed delay as the default fix.
- Flaky tests after navigation: navigation completion may precede client-side rendering. Wait for the specific next-page element or state that the test needs.
- Many tests break after a selector change: move duplicated selectors into the owning page or component object, then update that locator in one place.
- Page objects become hard to maintain: split out distinct pages or reusable regions when the class is accumulating unrelated responsibilities. Keep assertions about scenario outcomes in the tests.
- Waits behave inconsistently: review whether implicit and explicit waits are mixed; use explicit waits tied to the condition needed for each asynchronous interaction.
Or skip the browser setup
If the job is to save a rendered website image rather than exercise Selenium interactions, ScreenshotNeo provides a screenshot API and MCP server. Its one-call API example:
Quick Recap
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Cookie banners, newsletter popups, and chat widgets can be removed before capture; bot checks, blank pages, and failed loads are not billed. An MCP server provides the take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.
Sign up for ScreenshotNeo’s free plan.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Free tools Windows power users keep installed
One-click scans. No signup required.

