ui

package
v0.0.0-...-27b1c5b Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 19 Imported by: 0

README

UI Testing with Rod

This package provides UI testing capabilities using the rod browser automation library for the Gowright testing framework.

Features

  • Browser Automation: Full browser automation using Chrome/Chromium via Chrome DevTools Protocol
  • Element Interactions: Click, type, scroll, attribute access, and more
  • Assertions: Text validation, element existence, visibility checks, attribute validation
  • Screenshots: Capture full-page screenshots with automatic file management
  • Page Source: Extract complete HTML source for analysis
  • JavaScript Execution: Run custom JavaScript in the browser context
  • Wait Strategies: Wait for elements, text content, or custom conditions
  • Configurable: Headless/headed mode, window size, timeouts, user agents

Dependencies

The UI testing module requires:

  • github.com/go-rod/rod v0.116.2 - Browser automation library
  • Chrome/Chromium browser (automatically managed by rod if not present)
CI/CD Environment Setup

For GitHub Actions or other CI environments, ensure Chrome is installed:

- name: Install Chrome
  uses: browser-actions/setup-chrome@latest

The framework automatically applies CI-friendly arguments (--no-sandbox, --disable-dev-shm-usage, --disable-gpu) so no additional configuration is needed.

Supported Browsers

  • Chrome/Chromium (primary support) - Full feature support
  • Firefox - Limited support, requires additional configuration

Configuration

browserConfig := &config.BrowserConfig{
    Browser:        "chrome",           // Browser type: "chrome", "chromium"
    Headless:       true,               // Run in headless mode
    WindowSize:     "1920x1080",        // Browser window size
    Timeout:        30 * time.Second,   // Default timeout for operations
    ScreenshotPath: "./screenshots",    // Directory for screenshots
    UserAgent:      "custom-agent",     // Custom user agent string
    DisableImages:  false,              // Disable image loading for faster tests
    DisableCSS:     false,              // Disable CSS loading
    DisableJS:      false,              // Disable JavaScript execution
    BrowserArgs:    []string{           // Custom browser arguments (pending implementation)
        "--no-sandbox", 
        "--disable-dev-shm-usage",
    },
}
Default Chrome Arguments

The following Chrome arguments are automatically applied to improve the automation experience:

  • --no-default-browser-check - Prevents default browser check dialog
  • --no-first-run - Skips first run experience and setup wizard
  • --disable-fre - Disables first run experience
  • --no-sandbox - Required for containerized environments (CI/CD)
  • --disable-dev-shm-usage - Prevents /dev/shm issues in containers
  • --disable-gpu - Disable GPU acceleration for headless environments

Basic Usage

// Create and initialize tester
tester := ui.NewUITester()
err := tester.Initialize(browserConfig)
if err != nil {
    log.Fatal(err)
}
defer tester.Cleanup()

// Navigate to a page
err = tester.Navigate("https://example.com")

// Interact with elements
err = tester.Click("#button")
err = tester.Type("#input", "text")

// Get element text
text, err := tester.GetText("#element")

// Take screenshot
path, err := tester.TakeScreenshot("test")

// Wait for elements
err = tester.WaitForElement("#dynamic-element", 10*time.Second)

Test Structure

test := &core.UITest{
    Name: "Login Test",
    URL:  "https://example.com/login",
    Actions: []core.UIAction{
        {Type: "type", Selector: "#username", Value: "user"},
        {Type: "type", Selector: "#password", Value: "pass"},
        {Type: "click", Selector: "#login-btn"},
        {Type: "wait", Selector: ".dashboard"},
        {Type: "screenshot", Value: "after_login"},
    },
    Assertions: []core.UIAssertion{
        {Type: "element_exists", Selector: ".dashboard"},
        {Type: "text_contains", Selector: ".welcome", Expected: "Welcome"},
        {Type: "url_contains", Expected: "/dashboard"},
    },
}

result := tester.ExecuteTest(test)

Supported Actions

Action Description Parameters
navigate Navigate to URL value: URL to navigate to
click Click element selector: CSS selector of element
type Type text into element selector: CSS selector, value: text to type
wait Wait for element or duration selector: CSS selector (optional), value: duration string (optional)
scroll Scroll to element selector: CSS selector of element
screenshot Take screenshot value: filename (optional, auto-generated if empty)

Supported Assertions

Assertion Description Parameters
text_equals Element text equals expected value selector, expected
text_contains Element text contains expected value selector, expected
element_exists Element exists in DOM selector
element_visible Element is visible on page selector
attribute_equals Element attribute equals expected value selector, attribute, expected
page_title_equals Page title equals expected value expected
url_contains Current URL contains expected string expected

Advanced Features

Custom JavaScript Execution

Execute custom JavaScript in the browser context:

// Get page title
result, err := tester.ExecuteScript("return document.title;")

// Manipulate DOM
_, err = tester.ExecuteScript(`
    document.getElementById('myElement').style.backgroundColor = 'red';
    return 'Element highlighted';
`)

// Get complex data
data, err := tester.ExecuteScript(`
    return {
        url: window.location.href,
        userAgent: navigator.userAgent,
        cookies: document.cookie
    };
`)
Element Attributes

Access and validate element attributes:

// Get input value
value, err := tester.GetAttribute("#username", "value")

// Get element class
className, err := tester.GetAttribute(".button", "class")

// Get data attributes
dataValue, err := tester.GetAttribute("[data-id='123']", "data-value")
Element Visibility and Interaction
// Check if element is visible
visible, err := tester.IsElementVisible("#modal")

// Scroll element into view
err = tester.ScrollToElement("#bottom-element")

// Wait for specific text content
err = tester.WaitForText("#status", "Complete", 10*time.Second)
Screenshot Management
// Take screenshot with custom name
path, err := tester.TakeScreenshot("login_page")

// Screenshots are automatically saved as PNG files
// Path will be: "./screenshots/login_page.png" (if ScreenshotPath is configured)

Dismiss cookie notices and privacy banners programmatically:

// Navigate to page
err = tester.Navigate("https://example.com")

// Wait for page to load
time.Sleep(2 * time.Second)

// Dismiss any cookie notices that appeared
err = tester.DismissCookieNotices()
if err != nil {
    log.Printf("Failed to dismiss cookies: %v", err)
}

// Continue with your test...

The DismissCookieNotices() method automatically:

  • Finds and clicks "Accept", "Agree", "Allow" buttons
  • Hides common cookie banner elements
  • Removes overlay backgrounds
  • Handles popular consent management platforms (OneTrust, TrustArc, etc.)

Note: Browser argument configuration is pending rod API integration. Currently, cookie handling relies on the JavaScript-based dismissal method.

Error Handling

All methods return *core.GowrightError with specific error types:

  • core.BrowserError: Browser automation errors
  • core.ConfigurationError: Configuration issues

Dependencies

  • github.com/go-rod/rod: Browser automation library
  • Chrome/Chromium browser installed on system

Installation

Rod will automatically download and manage Chrome/Chromium if not found on the system.

Examples

See examples/ui-testing/ for complete examples.

Documentation

Overview

Package ui provides UI testing capabilities using browser automation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRecommendedCookieDisablingArgs

func GetRecommendedCookieDisablingArgs() []string

GetRecommendedCookieDisablingArgs returns browser arguments to minimize cookie notices

Types

type BrowserInstance

type BrowserInstance struct {
	ID         string
	CreatedAt  time.Time
	UsageCount int
}

BrowserInstance represents a browser instance in the pool

type BrowserPool

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

BrowserPool manages a pool of browser instances for concurrent testing

func NewBrowserPool

func NewBrowserPool(maxSize int, timeout time.Duration) (*BrowserPool, error)

NewBrowserPool creates a new browser pool

func (*BrowserPool) AcquireBrowser

func (bp *BrowserPool) AcquireBrowser(ctx context.Context) (*BrowserInstance, error)

AcquireBrowser acquires a browser instance from the pool

func (*BrowserPool) Cleanup

func (bp *BrowserPool) Cleanup() error

Cleanup closes all browser instances and cleans up the pool

func (*BrowserPool) GetStats

func (bp *BrowserPool) GetStats() *BrowserPoolStats

GetStats returns current pool statistics

func (*BrowserPool) Initialize

func (bp *BrowserPool) Initialize() error

Initialize initializes the browser pool

func (*BrowserPool) ReleaseBrowser

func (bp *BrowserPool) ReleaseBrowser(instance *BrowserInstance) error

ReleaseBrowser returns a browser instance to the pool

type BrowserPoolStats

type BrowserPoolStats struct {
	MaxSize       int `json:"max_size"`
	Available     int `json:"available"`
	InUse         int `json:"in_use"`
	TotalCreated  int `json:"total_created"`
	TotalAcquired int `json:"total_acquired"`
	TotalReleased int `json:"total_released"`
}

BrowserPoolStats holds statistics about browser pool usage

type CaptureInfo

type CaptureInfo struct {
	ID           string    `json:"id"`
	TestName     string    `json:"test_name"`
	StartTime    time.Time `json:"start_time"`
	MemoryUsed   int64     `json:"memory_used"`
	Size         int64     `json:"size"` // Alias for MemoryUsed for backward compatibility
	Type         string    `json:"type"` // Type of capture
	Compressed   bool      `json:"compressed"`
	FilePath     string    `json:"file_path"`
	Status       string    `json:"status"`
	OriginalSize int64     `json:"original_size"`
	FinalSize    int64     `json:"final_size"`
	Optimized    bool      `json:"optimized"`
}

CaptureInfo holds information about an active capture

type CaptureOptions

type CaptureOptions struct {
	IncludeTimestamp bool   `json:"include_timestamp"`
	CustomPrefix     string `json:"custom_prefix"`
	Format           string `json:"format"`
	Quality          int    `json:"quality"`
}

CaptureOptions holds options for advanced capture operations

type CaptureResult

type CaptureResult struct {
	ID           string `json:"id"`
	FilePath     string `json:"file_path"`
	OriginalSize int64  `json:"original_size"`
	FinalSize    int64  `json:"final_size"`
	Compressed   bool   `json:"compressed"`
	Optimized    bool   `json:"optimized"`
}

CaptureResult holds the result of a data capture operation

type CaptureStats

type CaptureStats struct {
	ScreenshotCount     int       `json:"screenshot_count"`
	PageSourceCount     int       `json:"page_source_count"`
	TotalFiles          int       `json:"total_files"`
	ScreenshotTotalSize int64     `json:"screenshot_total_size"`
	PageSourceTotalSize int64     `json:"page_source_total_size"`
	TotalSize           int64     `json:"total_size"`
	OldestCaptureTime   time.Time `json:"oldest_capture_time,omitempty"`
	NewestCaptureTime   time.Time `json:"newest_capture_time,omitempty"`
}

CaptureStats holds statistics about captured files

type ClickOptions

type ClickOptions struct {
	DoubleClick bool `json:"double_click,omitempty"`
	RightClick  bool `json:"right_click,omitempty"`
	Force       bool `json:"force,omitempty"`
}

ClickOptions holds options for click actions

type FailureCapture

type FailureCapture struct {
	TestName       string    `json:"test_name"`
	Error          error     `json:"error"`
	ScreenshotPath string    `json:"screenshot_path,omitempty"`
	PageSourcePath string    `json:"page_source_path,omitempty"`
	CaptureErrors  []string  `json:"capture_errors,omitempty"`
	Timestamp      time.Time `json:"timestamp"`
}

FailureCapture holds information about a test failure capture

type MemoryEfficientCaptureManager

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

MemoryEfficientCaptureManager handles memory-efficient screenshot and data capture

func NewMemoryEfficientCaptureManager

func NewMemoryEfficientCaptureManager(config *MemoryEfficientConfig) *MemoryEfficientCaptureManager

NewMemoryEfficientCaptureManager creates a new memory-efficient capture manager

func (*MemoryEfficientCaptureManager) CaptureDataStreamOptimized

func (m *MemoryEfficientCaptureManager) CaptureDataStreamOptimized(data []byte, testName, dataType string) (*CaptureResult, error)

CaptureDataStreamOptimized captures data with streaming and compression optimization

func (*MemoryEfficientCaptureManager) CapturePageSourceEfficient

func (m *MemoryEfficientCaptureManager) CapturePageSourceEfficient(tester core.UITester, testName string) (string, error)

CapturePageSourceEfficient captures page source with memory optimization

func (*MemoryEfficientCaptureManager) CaptureScreenshotEfficient

func (m *MemoryEfficientCaptureManager) CaptureScreenshotEfficient(tester core.UITester, testName string) (string, error)

CaptureScreenshotEfficient captures a screenshot with memory optimization

func (*MemoryEfficientCaptureManager) Cleanup

func (m *MemoryEfficientCaptureManager) Cleanup() error

Cleanup performs final cleanup of all resources

func (*MemoryEfficientCaptureManager) GetMemoryStats

func (m *MemoryEfficientCaptureManager) GetMemoryStats() MemoryStats

GetMemoryStats returns detailed memory statistics

func (*MemoryEfficientCaptureManager) GetStats

func (m *MemoryEfficientCaptureManager) GetStats() map[string]interface{}

GetStats returns current memory usage statistics

func (*MemoryEfficientCaptureManager) ReleaseCaptureMemory

func (m *MemoryEfficientCaptureManager) ReleaseCaptureMemory(captureID string) error

ReleaseCaptureMemory releases memory and resources for a specific capture

type MemoryEfficientConfig

type MemoryEfficientConfig struct {
	// Memory limits
	MaxMemoryUsageMB    int64 `json:"max_memory_usage_mb"`
	MaxScreenshotSizeMB int64 `json:"max_screenshot_size_mb"`

	// Compression settings
	EnableCompression   bool  `json:"enable_compression"`
	CompressionLevel    int   `json:"compression_level"`
	CompressThresholdKB int64 `json:"compress_threshold_kb"`

	// Image optimization
	MaxImageWidth  int `json:"max_image_width"`
	MaxImageHeight int `json:"max_image_height"`
	JPEGQuality    int `json:"jpeg_quality"`

	// Streaming settings
	EnableStreaming   bool  `json:"enable_streaming"`
	StreamChunkSizeKB int64 `json:"stream_chunk_size_kb"`

	// Cleanup settings
	AutoCleanupEnabled    bool          `json:"auto_cleanup_enabled"`
	CleanupInterval       time.Duration `json:"cleanup_interval"`
	MaxCaptureAge         time.Duration `json:"max_capture_age"`
	MaxConcurrentCaptures int           `json:"max_concurrent_captures"`
}

MemoryEfficientConfig holds configuration for memory-efficient operations

func DefaultMemoryEfficientConfig

func DefaultMemoryEfficientConfig() *MemoryEfficientConfig

DefaultMemoryEfficientConfig returns default configuration

type MemoryStats

type MemoryStats struct {
	ActiveCaptures    int   `json:"active_captures"`
	TotalMemoryUsedMB int64 `json:"total_memory_used_mb"`
	MaxMemoryUsageMB  int64 `json:"max_memory_usage_mb"`
	SystemMemoryMB    int64 `json:"system_memory_mb"`
	GCCount           int64 `json:"gc_count"`
}

MemoryStats holds memory usage statistics

type OptimizedCaptureOptions

type OptimizedCaptureOptions struct {
	MaxWidth      int  `json:"max_width"`
	MaxHeight     int  `json:"max_height"`
	ConvertToJPEG bool `json:"convert_to_jpeg"`
	JPEGQuality   int  `json:"jpeg_quality"`
}

OptimizedCaptureOptions holds options for optimized capture operations

func DefaultOptimizedCaptureOptions

func DefaultOptimizedCaptureOptions() *OptimizedCaptureOptions

DefaultOptimizedCaptureOptions returns default optimized capture options

type ScrollOptions

type ScrollOptions struct {
	Direction string `json:"direction"` // up, down, left, right, top, bottom
	Distance  int    `json:"distance,omitempty"`
	Speed     string `json:"speed,omitempty"` // slow, normal, fast
}

ScrollOptions holds options for scroll actions

type SelectOptions

type SelectOptions struct {
	ByValue bool `json:"by_value,omitempty"`
	ByText  bool `json:"by_text,omitempty"`
	ByIndex bool `json:"by_index,omitempty"`
}

SelectOptions holds options for select actions

type TestEvidence

type TestEvidence struct {
	TestName       string    `json:"test_name"`
	Timestamp      time.Time `json:"timestamp"`
	ScreenshotPath string    `json:"screenshot_path,omitempty"`
	PageSourcePath string    `json:"page_source_path,omitempty"`
	Errors         []string  `json:"errors,omitempty"`
}

TestEvidence holds captured evidence for a test

func (*TestEvidence) HasErrors

func (te *TestEvidence) HasErrors() bool

HasErrors returns true if there were any capture errors

func (*TestEvidence) HasPageSource

func (te *TestEvidence) HasPageSource() bool

HasPageSource returns true if page source was captured successfully

func (*TestEvidence) HasScreenshot

func (te *TestEvidence) HasScreenshot() bool

HasScreenshot returns true if screenshot was captured successfully

func (*TestEvidence) IsComplete

func (te *TestEvidence) IsComplete() bool

IsComplete returns true if both screenshot and page source were captured

type TypeOptions

type TypeOptions struct {
	ClearFirst bool          `json:"clear_first,omitempty"`
	Delay      time.Duration `json:"delay,omitempty"`
}

TypeOptions holds options for type actions

type UIActionOptions

type UIActionOptions struct {
	Timeout       time.Duration          `json:"timeout,omitempty"`
	WaitCondition string                 `json:"wait_condition,omitempty"`
	ScrollOptions *ScrollOptions         `json:"scroll_options,omitempty"`
	SelectOptions *SelectOptions         `json:"select_options,omitempty"`
	ClickOptions  *ClickOptions          `json:"click_options,omitempty"`
	TypeOptions   *TypeOptions           `json:"type_options,omitempty"`
	CustomOptions map[string]interface{} `json:"custom_options,omitempty"`
}

UIActionOptions holds additional options for UI actions

type UIActionType

type UIActionType string

UIActionType represents the type of UI action

const (
	ActionClick           UIActionType = "click"
	ActionType            UIActionType = "type"
	ActionNavigate        UIActionType = "navigate"
	ActionWait            UIActionType = "wait"
	ActionScrollToElement UIActionType = "scroll_to_element"
	ActionScrollPage      UIActionType = "scroll_page"
	ActionHover           UIActionType = "hover"
	ActionSelect          UIActionType = "select"
	ActionClear           UIActionType = "clear"
	ActionSubmit          UIActionType = "submit"
	ActionRefresh         UIActionType = "refresh"
	ActionGoBack          UIActionType = "go_back"
	ActionGoForward       UIActionType = "go_forward"
	// Mobile-specific actions
	ActionTap            UIActionType = "tap"
	ActionSwipe          UIActionType = "swipe"
	ActionSwipeLeft      UIActionType = "swipe_left"
	ActionSwipeRight     UIActionType = "swipe_right"
	ActionSwipeUp        UIActionType = "swipe_up"
	ActionSwipeDown      UIActionType = "swipe_down"
	ActionLongPress      UIActionType = "long_press"
	ActionPinch          UIActionType = "pinch"
	ActionSetOrientation UIActionType = "set_orientation"
)

type UIAssertionExecutor

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

UIAssertionExecutor executes UI assertions using the UITester

func NewUIAssertionExecutor

func NewUIAssertionExecutor(tester core.UITester) *UIAssertionExecutor

NewUIAssertionExecutor creates a new UIAssertionExecutor

func (*UIAssertionExecutor) ExecuteAssertion

func (uae *UIAssertionExecutor) ExecuteAssertion(assertion *core.UIAssertion) error

ExecuteAssertion executes a UI assertion

type UIAssertionOptions

type UIAssertionOptions struct {
	Timeout       time.Duration          `json:"timeout,omitempty"`
	CaseSensitive bool                   `json:"case_sensitive,omitempty"`
	Attribute     string                 `json:"attribute,omitempty"`
	Regex         bool                   `json:"regex,omitempty"`
	CustomOptions map[string]interface{} `json:"custom_options,omitempty"`
}

UIAssertionOptions holds additional options for UI assertions

type UIAssertionType

type UIAssertionType string

UIAssertionType represents the type of UI assertion

const (
	AssertElementPresent     UIAssertionType = "element_present"
	AssertElementNotPresent  UIAssertionType = "element_not_present"
	AssertElementVisible     UIAssertionType = "element_visible"
	AssertElementNotVisible  UIAssertionType = "element_not_visible"
	AssertTextEquals         UIAssertionType = "text_equals"
	AssertTextContains       UIAssertionType = "text_contains"
	AssertTextNotContains    UIAssertionType = "text_not_contains"
	AssertTextMatches        UIAssertionType = "text_matches"
	AssertAttributeEquals    UIAssertionType = "attribute_equals"
	AssertAttributeContains  UIAssertionType = "attribute_contains"
	AssertURLEquals          UIAssertionType = "url_equals"
	AssertURLContains        UIAssertionType = "url_contains"
	AssertTitleEquals        UIAssertionType = "title_equals"
	AssertTitleContains      UIAssertionType = "title_contains"
	AssertElementCount       UIAssertionType = "element_count"
	AssertPageSourceContains UIAssertionType = "page_source_contains"
)

type UICaptureManager

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

UICaptureManager handles screenshot and page source capture functionality

func NewUICaptureManager

func NewUICaptureManager(tester core.UITester, outputDir string) *UICaptureManager

NewUICaptureManager creates a new UICaptureManager

func (*UICaptureManager) AdvancedCaptureScreenshot

func (c *UICaptureManager) AdvancedCaptureScreenshot(testName string, options *CaptureOptions) (string, error)

AdvancedCaptureScreenshot captures a screenshot with advanced options

func (*UICaptureManager) CaptureOnFailure

func (c *UICaptureManager) CaptureOnFailure(testName string, testError error) (*FailureCapture, error)

CaptureOnFailure captures both screenshot and page source when a test fails

func (*UICaptureManager) CapturePageSource

func (c *UICaptureManager) CapturePageSource(testName string) (string, error)

CapturePageSource captures the current page source

func (*UICaptureManager) CapturePageSourceWithName

func (c *UICaptureManager) CapturePageSourceWithName(filename string) (string, error)

CapturePageSourceWithName captures page source with a specific filename

func (*UICaptureManager) CaptureScreenshot

func (c *UICaptureManager) CaptureScreenshot(testName string) (string, error)

CaptureScreenshot captures a screenshot with automatic filename generation

func (*UICaptureManager) CaptureScreenshotWithName

func (c *UICaptureManager) CaptureScreenshotWithName(filename string) (string, error)

CaptureScreenshotWithName captures a screenshot with a specific filename

func (*UICaptureManager) CaptureTestEvidence

func (c *UICaptureManager) CaptureTestEvidence(testName string) (*TestEvidence, error)

CaptureTestEvidence captures both screenshot and page source for a test

func (*UICaptureManager) CleanupOldCaptures

func (c *UICaptureManager) CleanupOldCaptures(maxAge time.Duration) error

CleanupOldCaptures removes capture files older than the specified duration

func (*UICaptureManager) GetCaptureStats

func (c *UICaptureManager) GetCaptureStats() (*CaptureStats, error)

GetCaptureStats returns statistics about captured files

func (*UICaptureManager) GetOutputDirectory

func (c *UICaptureManager) GetOutputDirectory() string

GetOutputDirectory returns the current output directory

func (*UICaptureManager) SetOutputDirectory

func (c *UICaptureManager) SetOutputDirectory(outputDir string)

SetOutputDirectory sets the output directory for captures

type UITester

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

UITester implements the UITester interface for browser automation

func NewUITester

func NewUITester() *UITester

NewUITester creates a new UI tester instance

func (*UITester) Cleanup

func (ut *UITester) Cleanup() error

Cleanup performs cleanup operations

func (*UITester) Click

func (ut *UITester) Click(selector string) error

Click clicks on an element identified by the selector

func (*UITester) DismissCookieNotices

func (ut *UITester) DismissCookieNotices() error

DismissCookieNotices attempts to dismiss common cookie notices and privacy banners

func (*UITester) ExecuteScript

func (ut *UITester) ExecuteScript(script string) (interface{}, error)

ExecuteScript executes JavaScript in the browser

func (*UITester) ExecuteTest

func (ut *UITester) ExecuteTest(test *core.UITest) *core.TestCaseResult

ExecuteTest executes a UI test and returns the result

func (*UITester) GetAttribute

func (ut *UITester) GetAttribute(selector, attribute string) (string, error)

GetAttribute retrieves an attribute value from an element

func (*UITester) GetName

func (ut *UITester) GetName() string

GetName returns the name of the tester

func (*UITester) GetPageSource

func (ut *UITester) GetPageSource() (string, error)

GetPageSource returns the current page source

func (*UITester) GetText

func (ut *UITester) GetText(selector string) (string, error)

GetText retrieves text from an element identified by the selector

func (*UITester) Initialize

func (ut *UITester) Initialize(cfg interface{}) error

Initialize sets up the UI tester with browser configuration

func (*UITester) IsElementVisible

func (ut *UITester) IsElementVisible(selector string) (bool, error)

IsElementVisible checks if an element is visible

func (*UITester) Navigate

func (ut *UITester) Navigate(url string) error

Navigate navigates to the specified URL

func (*UITester) ScrollPage

func (ut *UITester) ScrollPage(opts interface{}) error

ScrollPage scrolls page

func (*UITester) ScrollToElement

func (ut *UITester) ScrollToElement(selector string) error

ScrollToElement scrolls to make an element visible

func (*UITester) TakeScreenshot

func (ut *UITester) TakeScreenshot(filename string) (string, error)

TakeScreenshot captures a screenshot and returns the file path

func (*UITester) Type

func (ut *UITester) Type(selector, text string) error

Type types text into an element identified by the selector

func (*UITester) WaitForElement

func (ut *UITester) WaitForElement(selector string, timeout time.Duration) error

WaitForElement waits for an element to be present

func (*UITester) WaitForText

func (ut *UITester) WaitForText(selector, expectedText string, timeout time.Duration) error

WaitForText waits for an element to contain specific text

Jump to

Keyboard shortcuts

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