xpath

Construct robust XPath selectors for Biloba tests using DSL methods and predicates.

25|7|Updated Mar 3, 2023
One-click install
npx skills add https://github.com/onsi/biloba --skill xpath
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: xpath
Source: https://github.com/onsi/biloba/tree/main/plugins/biloba/skills/xpath
Command: npx skills add https://github.com/onsi/biloba --skill xpath

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill enables constructing robust XPath queries for Biloba actions and matchers, addressing scenarios where CSS or semantic locators fall short and more complex DOM relationships are required.

Core Features & Use Cases

  • DSL helpers: b.XPath(), b.RelativeXPath(), and chaining methods to build precise XPath strings.
  • Predicates and logic: compose with b.XPredicate() to refine conditions and combine selectors.
  • Tree navigation: navigate by Child, Descendant, Parent, Ancestor, and Sibling relations, including indexing with Nth/First/Last.
  • Text and attribute targeting: support for text() matching and attribute-based filtering to locate elements reliably.

Quick Start

Use b.XPath("div").WithClass("content") to construct a selector that matches a div with class content.

Frequently Asked Questions about xpath

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I use XPath selectors instead of CSS locators in automation testing?

Use XPath selectors when CSS locators are insufficient for navigating complex DOM structures, such as traversing parent and child relationships, matching specific text content, or filtering elements by attributes across nested frames.

How do I build XPath queries to target elements by class and attributes in Biloba tests?

Build XPath queries using the b.XPath() DSL method with chaining helpers to match elements by class and attributes. For example, b.XPath("div").WithClass("content") constructs a selector targeting a div with the class content.

Can I navigate parent and sibling relationships in complex DOM structures using XPath?

Yes, you can navigate tree relationships using Child, Descendant, Parent, Ancestor, and Sibling methods. These helpers allow precise traversal of complex DOM structures, including targeting specific positions with Nth, First, and Last indexing.

How do I refine XPath selector conditions with boolean predicates in testing?

Refine XPath selector conditions by composing boolean predicates with the b.XPredicate() method. This allows you to combine and filter selectors to target elements matching specific text and attribute criteria reliably.

Does Biloba XPath support relative selectors for targeting nested frame elements?

Yes, Biloba supports relative selectors via the b.RelativeXPath() DSL method. This enables precise element targeting across nested frames and complex DOM relationships where standard semantic locators fall short.

What are the limitations of using XPath for test automation element targeting?

XPath is not needed when CSS or semantic locators suffice, as it adds complexity. It should be reserved for scenarios requiring advanced DOM navigation like parent traversal, text matching, and nested frame attribute filtering.