Selenium

website·Indexed 43 days ago

https://www.selenium.dev/documentation/

A browser automation project supporting W3C WebDriver and WebDriver BiDi standards. Documentation covers driver sessions, element interactions, waiting strategies, driver management, and Selenium Grid.

Tokens
940
Snippets
0
Records
12
Agent score
74%

What's inside Selenium

  1. Scale test execution using Selenium Grid

    Selenium Grid is used to run tests in parallel across multiple machines. It allows for remote execution and scaling of test suites. Grid can be configured via CLI options or TOML configuration files. Advanced features include observability, GraphQL query support, custom Node configuration, and the use of external datastores.
  2. Use WebDriver BiDi for bidirectional browser automation

    WebDriver BiDi is a W3C standard bidirectional protocol that adds a WebSocket connection to WebDriver. It allows scripts to stream and react to browser events in real-time, such as network requests, console messages, and JavaScript errors. It serves as the cross-browser replacement for the Chrome DevTools Protocol (CDP). Key feature namespaces include network for networking and script for script-related events and logging.
  3. Use Selenium IDE for record-and-playback automation

    The Selenium IDE is a browser extension that allows users to record their interactions with a web application and play them back to automate repetitive tasks or create initial test scripts.
  4. Manage browser drivers with Selenium Manager

    Starting with Selenium 4.6, Selenium includes 'Selenium Manager', a Rust-based command-line tool that automatically resolves and downloads the correct driver for the browser being used. Because Selenium bindings use this tool by default, developers should no longer manually set driver executable paths or use third-party driver managers.
  5. Implement recommended Selenium test practices

    To reduce test flakiness and improve maintainability, the Selenium project recommends the following patterns:

    • Encouraged Behaviors: Use Page Object Models (POM), Domain Specific Languages (DSL), mock external services, maintain test independency, use a fresh browser instance per test, and utilize fluent APIs.
    • Discouraged Behaviors: Avoid automating CAPTCHAs, relying on file downloads, testing HTTP response codes via the browser, automating 2FA, or performing link spidering and performance testing through Selenium.
  6. Use WebDriver BiDi for bidirectional browser communication

    WebDriver BiDi is the current standard for handling events, network interception, console log access, and script injection. The previous Chrome DevTools Protocol (CDP) integration is considered legacy and should be avoided in favor of WebDriver BiDi.
  7. Implement waiting strategies in Selenium

    To ensure stable tests, prefer explicit waits using WebDriverWait and expected conditions over fixed sleeps (e.g., Thread.sleep() or time.sleep()). It is critical to avoid mixing implicit and explicit waits in the same test execution to prevent unpredictable wait times.
  8. Automate browser driver management with Selenium Manager

    Starting with Selenium 4.6, Selenium Manager is included by default. It is a Rust-based command-line tool that automatically downloads and configures the necessary browser drivers. Because Selenium bindings use this tool by default, developers no longer need to manually download drivers, specify driver paths in code, or use third-party driver managers.
  9. Configure browser capabilities using Options classes

    Desired Capabilities were removed in Selenium 4. To configure browser-specific settings or capabilities, use the per-browser Options classes (e.g., ChromeOptions, FirefoxOptions).
  10. Handle Selenium IDE and diagnostic warnings

    Selenium surfaces various diagnostics, annotations, and IDE warnings to help developers identify potential issues in their automation scripts. Refer to the official warnings documentation for detailed explanations of these signals.
  11. Understand Selenium's BiDi implementation API constraints

    Selenium's low-level WebDriver BiDi implementation classes are marked as internal. Developers should avoid using these internal classes directly and instead use the public API provided by Selenium for BiDi functionality.
  12. Troubleshoot common Selenium WebDriver errors

    Selenium provides dedicated resources for resolving common execution issues, including:

    • Driver Location Errors: Guidance for fixing 'Unable to Locate Driver' errors when the path to the driver executable is missing.
    • Command Logging: Methods to log Selenium commands to get detailed information about execution.
    • Version Migration: A specific guide for upgrading from Selenium 3 to Selenium 4.