find

package
v0.0.0-...-d572591 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package find provides enhanced element finding capabilities including CSS selectors, XPath support, wait functions, and element state checks.

Key features:

  • CSS selectors: Find elements by tag, ID, class, name, attributes
  • XPath support: Use XPath expressions for complex element selection
  • Wait functions: Wait for elements to appear, become visible, or contain text
  • Element state: Check if elements are visible, enabled, clickable

Example usage:

finder := find.New(page)

// Find element by CSS
element, err := finder.Find(find.Selector{
    TagName: "button",
    Class:   "submit",
})

// Wait for element
err := finder.WaitForElement(find.Selector{
    ID: "dynamic-content",
})

// Check element state
state := find.NewElementState(element)
visible, _ := state.IsVisible()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeXPath

func NormalizeXPath(selector string) string

NormalizeXPath converts synthetic xpath back to regular xpath

Types

type ElementState

type ElementState struct {
	// contains filtered or unexported fields
}

ElementState provides element state checks

func NewElementState

func NewElementState(el *rod.Element) *ElementState

NewElementState creates a new element state checker

func (*ElementState) IsClickable

func (s *ElementState) IsClickable() (bool, error)

IsClickable checks if element is clickable

func (*ElementState) IsEnabled

func (s *ElementState) IsEnabled() (bool, error)

IsEnabled checks if element is enabled

func (*ElementState) IsVisible

func (s *ElementState) IsVisible() (bool, error)

IsVisible checks if element is visible

type Finder

type Finder struct {
	// contains filtered or unexported fields
}

Finder provides enhanced element finding capabilities

func New

func New(page *rod.Page) *Finder

New creates a new Finder

func (*Finder) Find

func (f *Finder) Find(sel Selector) (*rod.Element, error)

Find finds a single element matching the selector

func (*Finder) FindAll

func (f *Finder) FindAll(sel Selector) ([]*rod.Element, error)

FindAll finds all elements matching the selector

func (*Finder) WaitForElement

func (f *Finder) WaitForElement(sel Selector) error

WaitForElement waits for an element to appear in the DOM

func (*Finder) WaitForText

func (f *Finder) WaitForText(sel Selector) error

WaitForText waits for specific text to appear

func (*Finder) WaitUntilVisible

func (f *Finder) WaitUntilVisible(el *rod.Element, timeout time.Duration) error

WaitUntilVisible waits until element is visible

type Selector

type Selector struct {
	TagName      string
	ID           string
	Class        string
	Name         string
	Text         string
	TextContains string
	Timeout      time.Duration
}

Selector represents element search criteria

func NewSelector

func NewSelector() Selector

NewSelector creates a new selector with defaults

func (Selector) BuildCSS

func (s Selector) BuildCSS() string

BuildCSS converts the selector to a CSS selector string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL