agentleFS
G1JoshiG1Joshi/Agent-Skills/skills/testing/selenium/SKILL.md

selenium

Skill15 starsChanged 44 days agoMITView on GitHub

Expert Selenium WebDriver automation covering multi-browser testing, explicit waits, and page objects. Use when automating web browsers, running legacy test automation, or interacting with web UIs.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use WebDriverWait with Expected Conditions:

    line 95
  2. Very specific:

    Always Use Explicit Waits: Never use Thread.sleep() or global implicit waits.

    line 116
  3. Very specific:

    Always Call driver.quit() in Teardown: Prevent orphaned driver and browser processes from consuming runner memory.

    line 118
  4. Very specific:

    Use fragile XPath hierarchies: Avoid absolute paths like /html/body/div[2]/div[1]/button.

    line 124
  5. Distinctive:

    Run UI tests for pure API validation: Use lightweight HTTP libraries for API testing.

    line 125

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Selenium

Selenium is an umbrella project for a range of tools and libraries that enable and support the automation of web browsers. It is the grandfather of browser automation and defined the W3C WebDriver standard.

When to Use

  • Enterprise Cross-Browser Automation: The foundational W3C standard for browser automation across Chrome, Firefox, Safari, and Edge.
  • Distributed Grid Scaling (Selenium Grid 4): Running enterprise test suites across distributed Docker/Kubernetes grid clusters.
  • Polyglot Test Automation: Maintaining shared test frameworks across Java, Python, C#, Ruby, and JavaScript teams.
  • Legacy Test Suite Maintenance: Extending long-standing enterprise test suites built on Selenium WebDriver.

Quick Start

WebDriver driver = new ChromeDriver();
driver.get("https://selenium.dev");
WebElement element = driver.findElement(By.id("search"));
element.sendKeys("webdriver");
element.submit();
driver.quit();

Core Concepts

W3C Standardized WebDriver Architecture

Clients communicate with browser-specific drivers (ChromeDriver, GeckoDriver) using standard W3C HTTP commands:

[ Test Script (Java/Python/C#) ] ──(W3C WebDriver Protocol)──→ [ Browser Driver (chromedriver) ] ──→ [ Browser ]

Explicit Waits with WebDriverWait & ExpectedConditions

Polls the DOM until specific conditions (visibility, clickability) are fulfilled:

// Java Selenium WebDriver 4
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
import java.time.Duration;

public class LoginPageTest {
    public static void main(String[] args) {
        WebDriver driver = new ChromeDriver();
        try {
            driver.get("https://app.example.com/login");

            WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
            WebElement emailInput = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("email")));
            emailInput.sendKeys("user@example.com");

            WebElement submitBtn = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[type='submit']")));
            submitBtn.click();
        } finally {
            driver.quit();
        }
    }
}

Page Object Model (POM) Design Pattern

Encapsulates page selectors and interactions into reusable classes:

# Python Page Object
class LoginPage:
    def __init__(self, driver):
        self.driver = driver
        self.username_input = (By.ID, "username")
        self.submit_button = (By.CSS_SELECTOR, "button.login")

    def login(self, username, password):
        self.driver.find_element(*self.username_input).send_keys(username)
        self.driver.find_element(*self.submit_button).click()

Common Patterns

Explicit Wait Strategy to Avoid Flakiness

Problem: Static time.sleep() calls either slow down test runs or cause random flakiness under load.

Solution: Use WebDriverWait with Expected Conditions:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get("https://example.com")

element = WebDriverWait(driver, 10).until(
    EC.visibility_of_element_located((By.ID, "submit-btn"))
)
element.click()

Best Practices

Do:

  • Always Use Explicit Waits: Never use Thread.sleep() or global implicit waits; use WebDriverWait with ExpectedConditions.
  • Implement the Page Object Model: Separate test assertions from UI selector mechanics.
  • Always Call driver.quit() in Teardown: Prevent orphaned driver and browser processes from consuming runner memory.
  • Leverage Selenium Manager: Allow Selenium 4.x to manage browser driver downloads automatically without manual binary management.

Don't:

  • Mix implicit and explicit waits: Mixing both causes unpredictable wait durations that multiply timeouts.
  • Use fragile XPath hierarchies: Avoid absolute paths like /html/body/div[2]/div[1]/button; use unique IDs or CSS selectors.
  • Run UI tests for pure API validation: Use lightweight HTTP libraries for API testing; reserve Selenium for user journeys.

Troubleshooting

ErrorCauseSolution
SessionNotCreatedException: This version of ChromeDriver only supports...Installed ChromeDriver version does not match installed Chrome browser.Use webdriver-manager or upgrade Chrome browser to match driver.
StaleElementReferenceExceptionDOM node was removed or re-rendered after element was found.Re-locate the element immediately prior to calling actions on it.
ElementClickInterceptedExceptionFloating banner, modal, or overlay blocking target click.Dismiss overlay or scroll element into view using JavaScript executor.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.