page-object-patterns

page-object-patterns is a cursor rule for Cursor from tugkanboz/awesome-cursorrules. It costs 1,767 tokens per session, scanned A, original, MIT.

A set of Selenium patterns for organizing browser tests with the Page Object Model, a way to keep page interactions in reusable classes. It includes shared page behavior, reusable interface components, chained actions, and locator strategies.

In plain words
What is it for?
Use it to build Selenium page classes, share common browser actions, model reusable UI components, and write readable multi-step test code.
Why use it?
It reduces duplicated browser-test code and keeps selectors and page interactions in one place. That makes tests easier to read and maintain when a website changes.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it to build Selenium page classes, share common browser actions, model reusable UI components, and write readable multi-step test code.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/tugkanboz/awesome-cursorrules/page-object-patterns
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/tugkanboz/awesome-cursorrules

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 page-object-patterns

README.md
[![agentmods](https://agentmods.dev/badge/rules/tugkanboz/awesome-cursorrules/page-object-patterns/github.svg)](https://agentmods.dev/rules/tugkanboz/awesome-cursorrules/page-object-patterns)
Your own site
<a href="https://agentmods.dev/rules/tugkanboz/awesome-cursorrules/page-object-patterns"><img src="https://agentmods.dev/badge/rules/tugkanboz/awesome-cursorrules/page-object-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for page-object-patterns

Your own site · 80×15
<a href="https://agentmods.dev/rules/tugkanboz/awesome-cursorrules/page-object-patterns"><img src="https://agentmods.dev/badge/rules/tugkanboz/awesome-cursorrules/page-object-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,767 This file is loaded in full into every session.
When invoked 1,767 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.01767 $0.01767
Opus 5.5 $0.00707 $0.00707
Sonnet 5.5 $0.00353 $0.00353
Haiku 4.5 $0.00177 $0.00177

Measured 1mo ago against content hash 95a577555e07, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

page-object-patterns 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 1mo 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.

example-structures/selenium-python/.cursor/rules/page-object-patterns.mdc · 215 lines

How it starts

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

Page Object Model Excellence

Advanced POM Architecture

  • Inheritance Hierarchy: BasePage class with common functionality
  • Component Pattern: Reusable UI components across pages
  • Fluent Interface: Method chaining for readable test code
  • Smart Locators: Dynamic locator strategies with fallbacks

Base Page Implementation

from typing import Optional, List, Union, Tuple
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import TimeoutException, StaleElementReferenceException
import logging

logger = logging.getLogger(__name__)

class BasePage:
    """Enhanced base page with advanced interaction methods."""
    
    def __init__(self, driver, timeout: int = 10):
        self.driver = driver
        self.wait = WebDriverWait(driver, timeout)
        self.timeout = timeout
        self.actions = ActionChains(driver)
    
    def find_element_safely(self, locator: Tuple[str, str], timeout: Optional[int] = None) -> Optional[WebElement]:
        """Find element with comprehensive error handling and retry logic."""
        timeout = timeout or self.timeout
        wait = WebDriverWait(self.driver, timeout)
        
        try:
            element = wait.until(EC.presence_of_element_located(locator))
            logger.debug(f"Element found successfully: {locator}")
            return element
        except TimeoutException:
            logger.warning(f"Element not found within {timeout}s: {locator}")
            return None
        except StaleElementReferenceException:
            logger.warning(f"Stale element detected, retrying: {locator}")
            return self.find_element_safely(locator, timeout)
    
    def click_when_clickable(self, locator: Tuple[str, str], timeout: Optional[int] = None) -> bool:
        """Click element only when it's clickable with retry logic."""
        timeout = timeout or self.timeout
        wait = WebDriverWait(self.driver, timeout)
        
        try:
            element = wait.until(EC.element_to_be_clickable(locator))
            
            # Scroll element into view before clicking
            self.driver.execute_script("arguments[0].scrollIntoView(true);", element)
            
            # Use Actions for more reliable clicking
            self.actions.move_to_element(element).click().perform()
            logger.info(f"Successfully clicked element: {locator}")
            return True
        except TimeoutException:
            logger.error(f"Element not clickable: {locator}")
            return False
        except Exception as e:
            logger.error(f"Click failed for {locator}: {str(e)}")
            return False
    
    def enter_text_safely(self, locator: Tuple[str, str], text: str, 
                         clear_first: bool = True, validate: bool = True) -> bool:
        """Enter text with validation and error handling."""
        element = self.find_element_safely(locator)
        if not element:
            return False
        
        try:
            # Scroll to element and focus
            self.driver.execute_script("arguments[0].scrollIntoView(true);", element)
            element.click()  # Focus the element
            
            if clear_first:
                element.clear()
            
            element.send_keys(text)
            
            # Verify text was entered correctly if validation is enabled
            if validate:
                entered_value = element.get_attribute('value')
                if entered_value == text:
                    logger.info(f"Text entered successfully: '{text}' in {locator}")
                    return True
                else:
                    logger.warning(f"Text entry verification failed. Expected: '{text}', Got: '{entered_value}'")
                    return False
            
            logger.info(f"Text entered (no validation): '{text}' in {locator}")
            return True
                
        except Exception as e:
            logger.error(f"Failed to enter text in {locator}: {str(e)}")
            return False

Read the full file on GitHub · 215 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. 1mo ago First seen · 215 lines · 1,767 tokens per session scan A 95a577555e07

Subscribe to this mod's changes

page-object-patterns is a cursor rule published in the GitHub repository tugkanboz/awesome-cursorrules (22 stars, last pushed 19d ago), licensed MIT. It adds 1,767 tokens to every session, about $0.0071 per session on Opus 5.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-08-30.