Free tools Windows power users keep installed
One-click scans. No signup required.
Object-oriented programming (OOP) helps make UI tests easier to read and maintain when it separates what a test is checking from how the current interface is operated. A Page Object Model (POM) is a practical way to apply that separation: page-specific classes hold locators and interaction methods, while tests describe scenarios and assert their outcomes. It is a useful design option, not a rule that every test or DOM element needs its own class.
Why use OOP in test automation?
A UI test can become hard to maintain when it mixes scenario logic with selectors, clicks, field entry, and page structure. If several tests each locate the same sign-in button, a UI change may require edits in several places. The tests can also become difficult to scan: the mechanics of operating the page obscure the behavior the test is meant to check.
OOP offers a way to group related data and behavior behind an interface. In test automation, that can mean an object represents a page or a meaningful part of one. A test calls an operation such as loginAs(username, password) rather than repeating the low-level steps. Selenium describes a Page Object as an object-oriented class that provides an interface to a page in the application under test.
The intended benefit is clearer responsibility and more localized maintenance, not a guaranteed reduction in effort. Selenium presents its practices as recommendations because one approach does not fit every environment.
#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.
What belongs in a Page Object?
A Page Object represents services or operations the page offers. It hides the page’s HTML structure from test authors and keeps page-specific interaction details together.
- Locators: selectors for fields, buttons, links, and other elements the page object operates.
- Page operations: methods that express meaningful actions, such as entering credentials and submitting a sign-in form.
- Page information: getters or queries that return information the test needs to examine, such as an error message.
A page object should not become a wrapper for every individual DOM element. Model useful page behavior and meaningful reusable regions, not classes for their own sake.
Where should assertions go?
Ordinarily, the test should own assertions about the behavior under test. The page object performs page operations and exposes information; the test decides whether the observed result meets the scenario’s expectation. Selenium states: “Page objects themselves should never make verifications or assertions.” It identifies a limited exception: a page object may check that the expected page loaded when it is created.
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.
For example, a sign-in page object can submit credentials and expose the resulting error text. The test then checks that text against the expected message. This keeps the page abstraction focused on interaction while making the test’s expected outcome visible where the scenario is defined.
Direct UI code versus a Page Object
| Concern | Locators and interactions directly in each test | Page Object approach |
|---|---|---|
| Change localization | A changed selector may need updates in every test that uses it. | A page-specific selector can often be updated in the corresponding object. |
| Scenario readability | Tests may interleave intent with low-level UI mechanics. | Tests can read more like workflows, using page-level operations. |
| Assertions | Usually visible in the test alongside interactions. | Remain in the test; page objects provide operations and information to assert on. |
| Reuse | Common mechanics can be duplicated across tests. | Shared page or component behavior can reduce duplication, if the abstraction reflects the UI. |
| Coupling | Tests know details of the current page structure. | Tests depend on the page object’s interface, which must remain clear and appropriately scoped. |
Selenium identifies reduced duplication and centralized maintenance as reasons to use page objects. These are design rationales, not measured guarantees that a particular project will require less maintenance.
Build a small Page Object Model
The following language-neutral sketch shows the division of responsibility. Replace the illustrative browser and assertion calls with the APIs of your chosen test framework and browser driver.
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.
- Define a page interface around the workflow. The sign-in page exposes an operation for submitting credentials and a query for the resulting message.
- Keep selectors and interaction details inside the page class. Tests should not need to know which CSS selector identifies the submit button.
- Write the scenario in test code. The test invokes the operation, observes the result through the page object, and performs the assertion.
- Keep page transitions explicit. If an operation navigates to another page, return or construct the appropriate page object where that makes the workflow clearer.
class SignInPage {
constructor(browser) {
this.browser = browser;
this.username = "#username";
this.password = "#password";
this.submit = "button[type='submit']";
this.error = ".error-message";
}
async loginAs(username, password) {
await this.browser.find(this.username).fill(username);
await this.browser.find(this.password).fill(password);
await this.browser.find(this.submit).click();
}
async errorMessage() {
return this.browser.find(this.error).text();
}
}
// In a test:
const signIn = new SignInPage(browser);
await signIn.loginAs("invalid-user", "wrong-password");
assertEqual(await signIn.errorMessage(), "Invalid username or password");
This is a structural example, not runnable code for a particular automation framework: browser.find, fill, click, and assertEqual are illustrative APIs. Use the equivalents provided by your selected tools.
Use composition for meaningful page components
Complex pages often contain regions with their own behavior, such as navigation, a product list, or a search panel. Selenium’s page-object guidance describes component objects and nesting. A page can compose objects for those regions rather than placing every method in one large class.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →class ProductList {
constructor(browser) {
this.browser = browser;
}
async openProduct(name) {
await this.browser.find(`[data-product='${name}']`).click();
}
}
class ShopPage {
constructor(browser) {
this.products = new ProductList(browser);
}
}
Composition is useful when it mirrors a real, reusable part of the interface. It is not automatically beneficial: an abstraction that hides simple behavior or couples unrelated areas can make tests harder to understand.
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
OOP is more than inheritance
Encapsulation, inheritance, and polymorphism are all object-oriented concepts, but applying OOP to test code does not mean building a deep inheritance tree. The O’Reilly chapter “Using Object-Oriented Principles in Test Code,” by Angie Jones in 97 Things Every Java Programmer Should Know, covers these concepts and discusses Page Object Model.
Prefer a component or page object composed from other objects when the interface has distinct reusable regions. Use inheritance when a base class represents genuinely shared behavior that belongs to its subclasses—not merely to avoid a few repeated lines. Selenium’s guidance supports component composition; it does not establish a universal rule against inheritance.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Keep tests independent of one another
Object structure alone does not make a test suite reliable. Selenium’s test-practice guidance also emphasizes independent tests and avoiding shared state. A test that depends on another test’s login, data changes, or browser session can fail when run alone or in a different order.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
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.
- Give each test the setup it needs rather than relying on a prior test’s side effects.
- Avoid mutable state shared across tests unless it is deliberately managed.
- Use a fresh browser for each test when the environment and framework permit it; Selenium lists this as an encouraged practice.
- Keep test data and cleanup responsibilities clear so failures are easier to reproduce.
When a Page Object is—and is not—worthwhile
It is a good fit when
- Multiple tests interact with the same page and duplicate its selectors or mechanics.
- UI details are obscuring scenario intent.
- A page has meaningful operations or reusable components that can be given a stable interface.
Keep it simpler when
- A test is small and isolated, with no meaningful reuse or maintenance problem to solve.
- An abstraction would only rename a single obvious action without hiding complexity.
- The proposed class structure would make navigation, assertions, or test setup less visible.
Start with the smallest abstraction that removes a real source of duplication or confusion. Revisit it when the interface or test suite reveals a concrete need; Selenium itself cautions that its recommendations are not a single approach for every environment.
Capture a visual record of a UI state
Some test workflows also need a screenshot of a page for a visual record or report. That is separate from the Page Object’s responsibility: keep browser interaction and test assertions in the automation code, and treat image capture as an evidence or reporting step.
Or skip the browser setup
A one-call screenshot request can capture a URL without setting up a browser in your own code. The response can be a PNG, JPEG, WebP, or PDF; see the ScreenshotNeo API documentation for request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo removes cookie banners, popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed; and its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Sign up for the free plan.
Frequently Asked Questions
Does every page need its own Page Object class?
No. Create page or component objects when they represent useful operations or reusable interface regions; avoid classes that add structure without clarifying behavior.
Is Page Object Model required by Selenium?
No. Selenium describes it as a recommended design approach and says its guidance is not a universal fit for every environment.
Quick Recap
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.




