Build each Selenium test so it prepares its own prerequisites, exercises one behavior, checks a coherent result, and leaves no state that another test needs. That is what makes a test atomic in practice: it can run independently, in any order, without relying on another test’s success. Selenium does not require exactly one assertion per test.
What makes a Selenium test atomic?
“Atomic” is a useful shorthand for a test with one clear purpose and self-contained state. Selenium’s guidance says to write each test as its own unit, independent of other tests, and to keep browser work to a discrete, short set of actions. The point is not to enforce a universal test length or assertion count; it is to make the outcome understandable and the test reliable when run alone or in a different order.
For example, do not make a test that verifies a website module depend on a separate test having created and published its content. That setup introduces timing and ordering dependencies. Instead, let the module test establish or stub the content it needs, while a separate test checks content creation and publishing. See Selenium’s test independency guidance.
Use a focused arrange–act–assert–cleanup cycle
- Arrange: create or select the data required for this behavior. Use a fixture, API, or other faster setup route when available.
- Act: perform the small sequence of browser interactions relevant to the behavior under test.
- Assert: use your test framework to check the result that answers the test’s purpose. Several assertions can be appropriate when they establish one coherent outcome.
- Clean up: remove or isolate data that could affect other tests, then end the browser session.
Keep unrelated stages of a business journey out of the same browser test. A test that creates an account, configures a product, adds it to a cart, pays, and submits feedback is slow and difficult to diagnose when it fails. Split it into independently runnable tests with distinct purposes; prepare each test’s preconditions without replaying every preceding step in the browser.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minute#1 Best Overall
Keep tests and browser state independent
Selenium recommends that tests be able to run in any order, without depending on other tests to succeed first. In practice, each test should own its required data and browser session. Avoid shared records that can be modified by another test, and clean stale records so they cannot be mistaken for fresh test data.
- Use distinct test data or a reliable per-test cleanup strategy to prevent collisions.
- Create a new WebDriver instance for each test, rather than sharing a session whose cookies, navigation, or browser state can leak between tests.
- Ensure driver teardown runs after both successful and failed tests. Selenium’s examples use a pytest fixture that yields a driver and quits it during teardown.
- Run tests in different orders during development or CI when practical; an order-dependent failure signals that a test is not fully self-contained.
Isolation makes parallel execution easier, but it does not by itself prevent contention. Parallel workers can still collide if they share accounts, records, environments, or other limited resources. Design test data and infrastructure for concurrent use. Selenium’s recommendations are in Avoid sharing state and Test dependency.
Rank #2
Use Selenium only for behavior that needs a browser
Functional browser tests can be expensive. Before adding browser actions, ask whether the behavior can be verified with a lighter-weight test. If the test is about application logic rather than browser behavior, a unit or service-level test may be a better fit. When browser coverage is needed, use an API, fixture, or database operation to arrange data where appropriate, then keep Selenium focused on the user-visible behavior.
Selenium provides tools for browser interaction, but it does not prescribe a single suite design that works for every application. Its test-practices documentation frames its advice as recommendations to adapt to the project. See Selenium Test Practices and the Selenium overview.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #3
Keep WebDriver and the test framework’s jobs separate
WebDriver controls the browser through the relevant browser driver. It performs actions and exposes browser state, but it does not decide whether expected and actual values match, determine pass or fail, or report test results. Your test framework—such as JUnit, NUnit, or another framework—runs tests and supplies assertions and reporting. Keep browser commands in the interaction part of the test and outcome checks in the framework’s assertion layer. Selenium’s component guide explains these roles.
Selenium IDE is a browser extension for recording and playing back interactions, while Selenium Grid distributes tests across machines and platform combinations. Grid can help scale execution; it does not remove the need for isolated test data and independent test behavior.
Rank #4
Common atomic-test failures and fixes
- A later test fails when run alone. It probably relies on a previous test’s data or side effects. Create its prerequisites in its own setup and give it its own reason to exist.
- Tests pass individually but fail in a suite. Look for shared records, stale data, reused browser sessions, and collisions between parallel workers. Isolate or clean the relevant state.
- One test takes a long time and has many unrelated failure points. Break the journey into tests with separate purposes and arrange each test’s starting state outside the browser when feasible.
- The browser is doing repetitive setup unrelated to the behavior. Move setup to a fixture, API, or other suitable mechanism, while retaining browser actions that are material to the behavior being tested.
- Assertions or reporting are being attributed to WebDriver. WebDriver drives the browser; use the test framework for assertions, pass/fail decisions, and reporting.
- “Atomic” is being interpreted as one assertion only. Selenium’s guidance emphasizes independence, isolation, short scope, and purpose; it does not set a mandatory assertion count.
Or skip the browser setup
If the job is capturing a website screenshot rather than testing browser behavior, ScreenshotNeo is a screenshot API and MCP server for developers. One GET request returns an image or PDF. For example, with cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchBest Value
See the ScreenshotNeo documentation for the API options. Cookie banners are accepted before capture and more than 60 known consent platforms, newsletter popups, and chat widgets can be removed; those steps can be disabled. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server lets AI agents use screenshot, page-info, and PDF-capture tools. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month, with no card required.
Frequently Asked Questions
Does an atomic Selenium test have to contain only one assertion?
No. Selenium’s guidance does not prescribe an assertion count; checks should establish one coherent outcome.
Does Selenium Grid make tests independent?
No. Grid distributes execution, while each test still needs isolated state and prerequisites.
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.




