All skills
fugazi avatar

/webapp-selenium-testing

@ef704d5

Author and maintain versioned Selenium WebDriver tests with Java and JUnit 5. Use for creating, debugging, or running Selenium specs, implementing Page Objects, handling explicit waits, capturing screenshots, or setting up Maven test projects. Supports Chrome, Firefox, and Edge. Keywords: Selenium WebDriver, Java, JUnit 5, Page Object Model, explicit waits, Maven, screenshots.

Use this Skill: https://skilld.dev/gh/fugazi/test-automation-skills-agents/webapp-selenium-testing

This session only. Nothing lands on disk.

referenceslocator-strategies-selectors.md

≈654 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Locator Strategies Selectors

Part of the webapp-selenium-testing skill. See SKILL.md for full context.

Related: this file was split from the original locator-strategies.md. See the other related files in this folder.

CSS Selectors (Flexible)

Use semantic CSS selectors when IDs aren't available:

// [ok] GOOD: Semantic CSS selectors
By.cssSelector("form#login input[type='email']")
By.cssSelector("button[aria-label='Close dialog']")
By.cssSelector("input[placeholder='Search...']")
By.cssSelector("table#users tbody tr")

// Attribute-based
By.cssSelector("[name='email']")
By.cssSelector("[type='submit']")
By.cssSelector("[role='button']")
By.cssSelector("[aria-expanded='true']")

// Combinators
By.cssSelector("div.container > form")          // Direct child
By.cssSelector("nav a")                          // Descendant
By.cssSelector("input + button")                 // Adjacent sibling
By.cssSelector("h1 ~ p")                         // General sibling

// Pseudo-selectors
By.cssSelector("li:first-child")
By.cssSelector("tr:nth-child(2)")
By.cssSelector("button:not([disabled])")

Name and Class Locators

// Name attribute (good for form fields)
By.name("username")
By.name("password")
By.name("remember-me")

// Class name (single class only)
By.className("btn-primary")
By.className("error-message")

// Multiple classes with CSS
By.cssSelector(".btn.btn-primary.large")

Link Text Locators

For anchor (<a>) elements:

// Exact text match
By.linkText("Sign up")
By.linkText("Forgot password?")

// Partial text match
By.partialLinkText("Sign")
By.partialLinkText("Learn more")

XPath Locators (Use Sparingly)

Use XPath only when CSS selectors can't achieve the goal:

// [!] USE WITH CAUTION: XPath for complex scenarios

// Text-based (CSS can't do this)
By.xpath("//button[text()='Submit']")
By.xpath("//button[normalize-space()='Submit']")
By.xpath("//button[contains(text(),'Submit')]")

// Parent traversal (CSS can't do this)
By.xpath("//input[@id='email']/..")
By.xpath("//input[@id='email']/ancestor::form")

// Sibling navigation
By.xpath("//label[text()='Email']/following-sibling::input")
By.xpath("//td[text()='John']/preceding-sibling::td")

// Position-based (when needed)
By.xpath("(//button[@class='action'])[1]")
By.xpath("//table//tr[last()]")

// Attribute contains
By.xpath("//input[contains(@class,'error')]")
By.xpath("//div[starts-with(@id,'product-')]")

// [no] NEVER: Absolute XPath
By.xpath("/html/body/div[1]/div[2]/form/button[3]")  // Extremely brittle!

Source: SKILL.md on GitHub

1 warning13d4 checks · Risk SAFE
  • Gen Agent Trust Hub13d

    The skill provides templates and scripts for Selenium WebDriver testing in Java. It is categorized as low risk due to potential indirect prompt injection vulnerabilities inherent in browser automation and the use of JavaScript execution in the browser context.

  • Socket13d

    No alerts

  • Snyk13d

    Risk: LOW · No issues

  • Runlayer6mo

    1/6 files flagged

Signed by skilld at ef704d5. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated 2 months ago

README badge

README badge for fugazi/test-automation-skills-agents/webapp-selenium-testing