Browser

Selector Targeting

Methods for defining which elements the browser's next action targets, including iframe context, shadow DOM, and repeating element groups.

Methods for defining which elements the browser's next action targets, including iframe context, shadow DOM, and repeating element groups.

WithSelector sets the active selector for the current unit of work. InElement scopes all subsequent selector searches to within a root element - useful for working within a specific container. InIframe switches context into an iframe. InShadowDom switches context into a shadow DOM subtree. InMainDom returns to the main document from any frame or shadow context. WithAllThatMatch is used when a selector intentionally matches multiple repeating elements (such as table rows). WithPersistentSelector adds a selector that applies across all units of work.

TIP

Each WithSelector call defines a new unit of work. Multiple selectors in a single unit of work (via chaining) are evaluated together as a group. WithAllThatMatch tells GPAL to expect and process multiple matching elements rather than just the first.

Examples

GPAL Fluent: High-level fluent C# API

//InElement, InIframe, and InShadowDom all push a new DOM context - pair them with InMainDom() when you need to return to the top-level document.

// Target a specific element GPAL.Browser .GoTo("https://example.com") .WithSelector("#submit-btn") .LeftClick(); // Work within an iframe GPAL.Browser .GoTo("https://example.com") .InIframe("#payment-frame") .WithSelector("#card-number") .FillInFrom("4111111111111111") .InMainDom(); // Target all rows in a repeating list GPAL.Browser .GoTo("https://example.com/products") .WithSelector(".product-row") .WithAllThatMatch(100) .GetGrid(out var products);