Documentation
¶
Overview ¶
Package ui provides UI testing capabilities using browser automation
Index ¶
- func GetRecommendedCookieDisablingArgs() []string
- type BrowserInstance
- type BrowserPool
- type BrowserPoolStats
- type CaptureInfo
- type CaptureOptions
- type CaptureResult
- type CaptureStats
- type ClickOptions
- type FailureCapture
- type MemoryEfficientCaptureManager
- func (m *MemoryEfficientCaptureManager) CaptureDataStreamOptimized(data []byte, testName, dataType string) (*CaptureResult, error)
- func (m *MemoryEfficientCaptureManager) CapturePageSourceEfficient(tester core.UITester, testName string) (string, error)
- func (m *MemoryEfficientCaptureManager) CaptureScreenshotEfficient(tester core.UITester, testName string) (string, error)
- func (m *MemoryEfficientCaptureManager) Cleanup() error
- func (m *MemoryEfficientCaptureManager) GetMemoryStats() MemoryStats
- func (m *MemoryEfficientCaptureManager) GetStats() map[string]interface{}
- func (m *MemoryEfficientCaptureManager) ReleaseCaptureMemory(captureID string) error
- type MemoryEfficientConfig
- type MemoryStats
- type OptimizedCaptureOptions
- type ScrollOptions
- type SelectOptions
- type TestEvidence
- type TypeOptions
- type UIActionOptions
- type UIActionType
- type UIAssertionExecutor
- type UIAssertionOptions
- type UIAssertionType
- type UICaptureManager
- func (c *UICaptureManager) AdvancedCaptureScreenshot(testName string, options *CaptureOptions) (string, error)
- func (c *UICaptureManager) CaptureOnFailure(testName string, testError error) (*FailureCapture, error)
- func (c *UICaptureManager) CapturePageSource(testName string) (string, error)
- func (c *UICaptureManager) CapturePageSourceWithName(filename string) (string, error)
- func (c *UICaptureManager) CaptureScreenshot(testName string) (string, error)
- func (c *UICaptureManager) CaptureScreenshotWithName(filename string) (string, error)
- func (c *UICaptureManager) CaptureTestEvidence(testName string) (*TestEvidence, error)
- func (c *UICaptureManager) CleanupOldCaptures(maxAge time.Duration) error
- func (c *UICaptureManager) GetCaptureStats() (*CaptureStats, error)
- func (c *UICaptureManager) GetOutputDirectory() string
- func (c *UICaptureManager) SetOutputDirectory(outputDir string)
- type UITester
- func (ut *UITester) Cleanup() error
- func (ut *UITester) Click(selector string) error
- func (ut *UITester) DismissCookieNotices() error
- func (ut *UITester) ExecuteScript(script string) (interface{}, error)
- func (ut *UITester) ExecuteTest(test *core.UITest) *core.TestCaseResult
- func (ut *UITester) GetAttribute(selector, attribute string) (string, error)
- func (ut *UITester) GetName() string
- func (ut *UITester) GetPageSource() (string, error)
- func (ut *UITester) GetText(selector string) (string, error)
- func (ut *UITester) Initialize(cfg interface{}) error
- func (ut *UITester) IsElementVisible(selector string) (bool, error)
- func (ut *UITester) Navigate(url string) error
- func (ut *UITester) ScrollPage(opts interface{}) error
- func (ut *UITester) ScrollToElement(selector string) error
- func (ut *UITester) TakeScreenshot(filename string) (string, error)
- func (ut *UITester) Type(selector, text string) error
- func (ut *UITester) WaitForElement(selector string, timeout time.Duration) error
- func (ut *UITester) WaitForText(selector, expectedText string, timeout time.Duration) error
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 ¶
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" 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 (*UITester) DismissCookieNotices ¶
DismissCookieNotices attempts to dismiss common cookie notices and privacy banners
func (*UITester) ExecuteScript ¶
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 ¶
GetAttribute retrieves an attribute value from an element
func (*UITester) GetPageSource ¶
GetPageSource returns the current page source
func (*UITester) Initialize ¶
Initialize sets up the UI tester with browser configuration
func (*UITester) IsElementVisible ¶
IsElementVisible checks if an element is visible
func (*UITester) ScrollPage ¶
ScrollPage scrolls page
func (*UITester) ScrollToElement ¶
ScrollToElement scrolls to make an element visible
func (*UITester) TakeScreenshot ¶
TakeScreenshot captures a screenshot and returns the file path
func (*UITester) WaitForElement ¶
WaitForElement waits for an element to be present