selenium

selenium is a cursor rule for Cursor from sanjeed5/awesome-cursor-rules-mdc. It costs 1,856 tokens per session, scanned A, original, CC0-1.0.

A set of coding rules for Selenium with Python, a toolset for controlling web browsers from code. It recommends the Page Object Model, which keeps page elements and browser actions separate from test or scraping logic.

In plain words
What is it for?
Use it when writing automated browser tests or web-scraping scripts with Selenium, including reusable page objects and explicit waits.
Why use it?
It makes browser tests and scraping scripts easier to update when a website's layout or selectors change.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it when writing automated browser tests or web-scraping scripts with Selenium, including reusable page objects and explicit waits.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/sanjeed5/awesome-cursor-rules-mdc/selenium
About the project

awesome-cursor-rules-mdc is a generator that creates Cursor MDC rule files from structured library information, using semantic search and language models to gather and organize guidance. Developers use it to produce reusable rules for libraries in Cursor, and the catalogue includes 200 of those rules.

sanjeed5/awesome-cursor-rules-mdc · 3,571 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/sanjeed5/awesome-cursor-rules-mdc

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for selenium

README.md
[![agentmods](https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/selenium.svg)](https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/selenium)
Your own site
<a href="https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/selenium"><img src="https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/selenium.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,856 This file is loaded in full into every session.
When invoked 1,856 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01856 $0.01856
Opus 5 $0.00928 $0.00928
Sonnet 5 $0.00371 $0.00371
Haiku 4.5 $0.00186 $0.00186

Measured 3d ago against content hash cb649d2e4ed6, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

selenium scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules-mdc/selenium.mdc · 229 lines

How it starts

The opening of the file, as written. The whole thing — 229 lines — stays where its author put it; the contents beside it link to each section on GitHub.

selenium Best Practices

This guide outlines the definitive best practices for using Selenium with Python. Adhere to these rules to ensure your automation scripts are robust, maintainable, and performant.

1. Code Organization: Page Object Model (POM)

Always structure your Selenium code using the Page Object Model (POM). This separates UI elements and interactions from your test or scraping logic, making your code highly maintainable and reusable.

BAD: Logic and locators mixed

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://example.com/login")
driver.find_element(By.ID, "username").send_keys("user")
driver.find_element(By.ID, "password").send_keys("pass")
driver.find_element(By.XPATH, "//button[text()='Login']").click()
# ... more logic

GOOD: Page Object Model

# pages/base_page.py
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

class BasePage:
    def __init__(self, driver: WebDriver, timeout: int = 10):
        self.driver = driver
        self.wait = WebDriverWait(driver, timeout)

    def _find_element(self, by: By, value: str):
        return self.wait.until(EC.presence_of_element_located((by, value)))

# pages/login_page.py
from pages.base_page import BasePage
from selenium.webdriver.common.by import By

class LoginPage(BasePage):
    URL = "https://example.com/login"
    _USERNAME_INPUT = (By.ID, "username")
    _PASSWORD_INPUT = (By.ID, "password")
    _LOGIN_BUTTON = (By.XPATH, "//button[text()='Login']")

    def open(self):
        self.driver.get(self.URL)

    def login(self, username, password):
        self._find_element(*self._USERNAME_INPUT).send_keys(username)
        self._find_element(*self._PASSWORD_INPUT).send_keys(password)
        self._find_element(*self._LOGIN_BUTTON).click()

# tests/test_login.py (or main scraping script)
from selenium import webdriver
from pages.login_page import LoginPage

def test_successful_login():
    driver = webdriver.Chrome()
    try:
        login_page = LoginPage(driver)
        login_page.open()
        login_page.login("valid_user", "valid_pass")
        assert "dashboard" in driver.current_url # Example assertion
    finally:
        driver.quit()

Read the full file on GitHub · 229 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 229 lines · 1,856 tokens per session scan A cb649d2e4ed6

Subscribe to this mod's changes

selenium is a cursor rule published in the GitHub repository sanjeed5/awesome-cursor-rules-mdc (3,571 stars, last pushed 3mo ago), licensed CC0-1.0. It adds 1,856 tokens to every session, about $0.0093 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.