browser

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 39 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Left   Button = `left`
	Middle        = `middle`
	Right         = `right`
)
View Source
const (
	Pressed  MouseAction = `mousePressed`
	Released             = `mouseReleased`
	Moved                = `mouseMoved`
	Scrolled             = `mouseWheel`
)
View Source
const (
	KeyPressed  KeyboardAction = `keyDown`
	KeyReleased                = `keyUp`
	KeyRaw                     = `rawKeyDown`
)

Variables

View Source
var DebuggerInnerPort = 9222
View Source
var DefaultContainerMemory = `512m`
View Source
var DefaultContainerSharedMemory = `256m`
View Source
var DefaultDebuggingPort = 0 // 0 = allocate an ephemeral port
View Source
var DefaultReplyTimeout = 30 * time.Second
View Source
var DefaultStartURL = `about:blank`
View Source
var DefaultStartWait = 10 * time.Second
View Source
var DefaultUserDirPath = `/var/tmp`
View Source
var ExitRequested = errors.New(`exit requested`)
View Source
var MaxUnreadEvents = 1024
View Source
var NotImplemented = errors.New(`Not Implemented`)
View Source
var ProcessExitCheckInterval = 125 * time.Millisecond
View Source
var ProcessExitMaxWait = 10 * time.Second

Functions

func IsExitRequestedErr added in v0.9.27

func IsExitRequestedErr(err error) bool

func IsNotImplementedErr added in v0.9.50

func IsNotImplementedErr(err error) bool

func LocateChromeExecutable

func LocateChromeExecutable() string

func StopAllActiveBrowsers added in v0.10.0

func StopAllActiveBrowsers()

Types

type BookmarkBarPreferences

type BookmarkBarPreferences struct {
	ShowOnAllTabs bool `json:"show_on_all_tabs"`
}

type Browser

type Browser struct {
	utils.Runtime
	Command                     argonaut.CommandName   `argonaut:",joiner=[=]"`
	App                         string                 `argonaut:"app,long"`
	DisableGPU                  bool                   `argonaut:"disable-gpu,long"`
	HideScrollbars              bool                   `argonaut:"hide-scrollbars,long"`
	Headless                    bool                   `argonaut:"headless,long"`
	Kiosk                       bool                   `argonaut:"kiosk,long"`
	ProxyBypassList             []string               `argonaut:"proxy-bypass-list,long,delimiters=[;]"`
	ProxyServer                 string                 `argonaut:"proxy-server,long"`
	RemoteDebuggingPort         int                    `argonaut:"remote-debugging-port,long"`
	RemoteDebuggingAddress      string                 `argonaut:"remote-debugging-address,long"`
	UserDataDirectory           string                 `argonaut:"user-data-dir,long"`
	DefaultBackgroundColor      string                 `argonaut:"default-background-color,long"`
	DisableSessionCrashedBubble bool                   `argonaut:"disable-session-crashed-bubble,long"`
	DisableInfobars             bool                   `argonaut:"disable-infobars,long"`
	SingleProcess               bool                   `argonaut:"single-process,long"`
	DisableSharedMemory         bool                   `argonaut:"disable-dev-shm-usage,long"`
	DisableSetuidSandbox        bool                   `argonaut:"disable-setuid-sandbox,long"`
	NoZygote                    bool                   `argonaut:"no-zygote,long"`
	NoSandbox                   bool                   `argonaut:"no-sandbox,long"`
	UserAgent                   string                 `argonaut:"user-agent,long"`
	URL                         string                 `argonaut:",positional"`
	StartWait                   time.Duration          `argonaut:"-"`
	Environment                 map[string]interface{} `argonaut:"-"`
	Directory                   string                 `argonaut:"-"`
	Preferences                 *Preferences           `argonaut:"-"`
	ID                          string                 `argonaut:"-"`
	RemoteAddress               string
	// contains filtered or unexported fields
}

func NewBrowser

func NewBrowser() *Browser

func Start

func Start() (*Browser, error)

func (*Browser) IsConnected added in v0.10.0

func (self *Browser) IsConnected() bool

func (*Browser) Launch

func (self *Browser) Launch() error

func (*Browser) SetScope

func (self *Browser) SetScope(fsenv utils.Runtime)

func (*Browser) Stop

func (self *Browser) Stop() error

func (*Browser) Tab

func (self *Browser) Tab() *Tab

func (*Browser) Wait

func (self *Browser) Wait() error

type BrowserPreferences

type BrowserPreferences struct {
	ShowHomeButton                    bool     `json:"show_home_button"`
	CheckDefaultBrowser               bool     `json:"check_default_browser"`
	DefaultBrowserInfobarLastDeclined string   `json:"default_browser_infobar_last_declined"`
	EnabledLabsExperiments            []string `json:"enabled_labs_experiments,omitempty"`
}

type Button

type Button string

func (Button) String

func (self Button) String() string

type DistributionPreferences

type DistributionPreferences struct {
	DoNotCreateAnyShortcuts              bool   `json:"do_not_create_any_shortcuts"`
	DoNotCreateDesktopShortcut           bool   `json:"do_not_create_desktop_shortcut"`
	DoNotCreateQuickLaunchShortcut       bool   `json:"do_not_create_quick_launch_shortcut"`
	DoNotCreateTaskbarShortcut           bool   `json:"do_not_create_taskbar_shortcut"`
	DoNotLaunchChrome                    bool   `json:"do_not_launch_chrome"`
	DoNotRegisterForUpdateLaunch         bool   `json:"do_not_register_for_update_launch"`
	ImportBookmarks                      bool   `json:"import_bookmarks"`
	ImportBookmarksFromFile              string `json:"import_bookmarks_from_file,omitempty"`
	ImportHistory                        bool   `json:"import_history"`
	ImportHomePage                       bool   `json:"import_home_page"`
	ImportSearchEngine                   bool   `json:"import_search_engine"`
	MakeChromeDefault                    bool   `json:"make_chrome_default"`
	MakeChromeDefaultForUser             bool   `json:"make_chrome_default_for_user"`
	PingDelay                            int    `json:"ping_delay,omitempty"`
	RequireEula                          bool   `json:"require_eula"`
	SuppressFirstRunBubble               bool   `json:"suppress_first_run_bubble"`
	SuppressFirstRunDefaultBrowserPrompt bool   `json:"suppress_first_run_default_browser_prompt"`
	SystemLevel                          bool   `json:"system_level"`
	VerboseLogging                       bool   `json:"verbose_logging"`
}

type Event

type Event struct {
	ID        int
	Name      string
	Result    *maputil.Map
	Params    *maputil.Map
	Error     error
	Timestamp time.Time
}

func (*Event) P

func (self *Event) P() *maputil.Map

func (*Event) R

func (self *Event) R() *maputil.Map

func (*Event) String

func (self *Event) String() string

type EventCallbackFunc

type EventCallbackFunc func(event *Event)

type EventWaiter

type EventWaiter struct {
	Pattern glob.Glob
	Events  chan *Event
	// contains filtered or unexported fields
}

func NewEventWaiter

func NewEventWaiter(tab *Tab, eventGlob string) (*EventWaiter, error)

func (*EventWaiter) Match

func (self *EventWaiter) Match(event *Event) bool

func (*EventWaiter) Remove

func (self *EventWaiter) Remove()

func (*EventWaiter) Wait

func (self *EventWaiter) Wait(timeout time.Duration) (*Event, error)

type KeyboardAction

type KeyboardAction string

func (KeyboardAction) String

func (self KeyboardAction) String() string

type KeyboardActionConfig

type KeyboardActionConfig struct {
	Action  KeyboardAction `json:"action" default:"keyDown"`
	Alt     bool           `json:"alt,omitempty"`
	Control bool           `json:"control,omitempty"`
	Meta    bool           `json:"meta,omitempty"`
	Shift   bool           `json:"shift,omitempty"`
	KeyCode int            `json:"keycode,omitempty"`
}

type MouseAction

type MouseAction string

func (MouseAction) String

func (self MouseAction) String() string

type MouseActionConfig

type MouseActionConfig struct {
	Action  MouseAction `json:"action" default:"mouseMoved"`
	Button  Button      `json:"button,omitempty"`
	Alt     bool        `json:"alt,omitempty"`
	Control bool        `json:"control,omitempty"`
	Meta    bool        `json:"meta,omitempty"`
	Shift   bool        `json:"shift,omitempty"`
	WheelX  float64     `json:"wheelX,omitempty"`
	WheelY  float64     `json:"wheelY,omitempty"`
	Count   int         `json:"count,omitempty"`
}

type NetworkInterceptFunc added in v0.9.33

type NetworkInterceptFunc func(*Tab, *NetworkRequestPattern, *Event) *NetworkInterceptResponse

type NetworkInterceptResponse added in v0.9.33

type NetworkInterceptResponse struct {
	URL          string
	Method       string
	Body         io.Reader
	PostData     map[string]interface{}
	Header       http.Header
	Error        error
	AuthResponse string
	Username     string
	Password     string
	Autoremove   bool
}

func (*NetworkInterceptResponse) ToMap added in v0.9.33

func (self *NetworkInterceptResponse) ToMap(id string) map[string]interface{}

type NetworkRequest added in v0.9.24

type NetworkRequest struct {
	ID         string
	Request    *Event
	Response   *Event
	Failure    *Event
	Completion *Event
}

func (*NetworkRequest) Error added in v0.9.24

func (self *NetworkRequest) Error() error

func (*NetworkRequest) IsCompleted added in v0.9.24

func (self *NetworkRequest) IsCompleted() bool

func (*NetworkRequest) R added in v0.9.24

func (self *NetworkRequest) R() *maputil.Map

type NetworkRequestPattern added in v0.9.33

type NetworkRequestPattern struct {
	URL               string
	ResourceType      string
	InterceptionStage string
	Pattern           glob.Glob
}

func (*NetworkRequestPattern) ToMap added in v0.9.33

func (self *NetworkRequestPattern) ToMap() map[string]interface{}

type PageInfo

type PageInfo struct {
	URL   string `json:"url"`
	State string `json:"state"`
	// contains filtered or unexported fields
}

type Preferences

type Preferences struct {
	Homepage             string                   `json:"homepage"`
	HomepageIsNewTabPage bool                     `json:"homepage_is_newtabpage"`
	Browser              *BrowserPreferences      `json:"browser,omitempty"`
	Session              *SessionPreferences      `json:"session,omitempty"`
	BookmarkBar          *BookmarkBarPreferences  `json:"bookmark_bar,omitempty"`
	SyncPromo            *SyncPromoPreferences    `json:"sync_promo,omitempty"`
	Distribution         *DistributionPreferences `json:"distribution,omitempty"`
	FirstRunTabs         []string                 `json:"first_run_tabs,omitempty"`
}

func GetDefaultPreferences

func GetDefaultPreferences() *Preferences

type RPC

type RPC struct {
	URL string
	// contains filtered or unexported fields
}

func NewRPC

func NewRPC(wsUrl string) (*RPC, error)

func (*RPC) Call

func (self *RPC) Call(method string, params map[string]interface{}, timeout time.Duration) (*RpcMessage, error)

func (*RPC) CallAsync

func (self *RPC) CallAsync(method string, params map[string]interface{}) error

func (*RPC) Close

func (self *RPC) Close() error

func (*RPC) Messages

func (self *RPC) Messages() <-chan *RpcMessage

func (*RPC) Send

func (self *RPC) Send(message *RpcMessage, timeout time.Duration) (*RpcMessage, error)

func (*RPC) SynthesizeEvent

func (self *RPC) SynthesizeEvent(message RpcMessage)

type RpcError

type RpcError struct {
	Code    int
	Message string
}

func (*RpcError) Error

func (self *RpcError) Error() string

type RpcMessage

type RpcMessage struct {
	ID     int64                  `json:"id"`
	Method string                 `json:"method"`
	Params map[string]interface{} `json:"params,omitempty"`
	Result map[string]interface{} `json:"result,omitempty"`
	Error  map[string]interface{} `json:"error,omitempty"`
}

func (*RpcMessage) P

func (self *RpcMessage) P() *maputil.Map

func (*RpcMessage) R

func (self *RpcMessage) R() *maputil.Map

func (*RpcMessage) String

func (self *RpcMessage) String() string

type SessionPreferences

type SessionPreferences struct {
	RestoreOnStartup int      `json:"restore_on_startup"`
	StartupUrls      []string `json:"startup_urls,omitempty"`
}

type SyncPromoPreferences

type SyncPromoPreferences struct {
	ShowOnFirstRunAllowed bool `json:"show_on_first_run_allowed"`
}

type Tab

type Tab struct {
	AfterCommandDelay time.Duration
	// contains filtered or unexported fields
}

func (*Tab) AddNetworkIntercept added in v0.9.33

func (self *Tab) AddNetworkIntercept(urlPattern string, waitForHeaders bool, fn NetworkInterceptFunc) error

func (*Tab) AsyncRPC

func (self *Tab) AsyncRPC(module string, method string, args map[string]interface{}) error

func (*Tab) ClearNetworkIntercepts added in v0.9.33

func (self *Tab) ClearNetworkIntercepts() error

func (*Tab) CreateAccumulator

func (self *Tab) CreateAccumulator(filter string) (*eventAccumulator, error)

func (*Tab) CreateEventWaiter

func (self *Tab) CreateEventWaiter(eventGlob string) (*EventWaiter, error)

func (*Tab) Disconnect

func (self *Tab) Disconnect() error

func (*Tab) ElementPosition added in v0.9.50

func (self *Tab) ElementPosition(element *dom.Element) (dom.Dimensions, error)

func (*Tab) ElementQuery added in v0.9.50

func (self *Tab) ElementQuery(selector dom.Selector, parent *dom.Selector) ([]*dom.Element, error)

func (*Tab) Emit

func (self *Tab) Emit(method string, params map[string]interface{})

func (*Tab) Evaluate added in v0.9.50

func (self *Tab) Evaluate(stmt string, exposed ...string) (interface{}, error)

func (*Tab) EvaluateOn added in v0.9.50

func (self *Tab) EvaluateOn(element *dom.Element, stmt string, exposed ...string) (interface{}, error)

func (*Tab) GetLoaderRequest

func (self *Tab) GetLoaderRequest(id string) (netreq *NetworkRequest)

func (*Tab) GetMostRecentFrame

func (self *Tab) GetMostRecentFrame() (int64, []byte, int, int)

func (*Tab) ID

func (self *Tab) ID() string

func (*Tab) Info

func (self *Tab) Info() *PageInfo

func (*Tab) IsScreencasting

func (self *Tab) IsScreencasting() bool

func (*Tab) MoveMouse

func (self *Tab) MoveMouse(x float64, y float64, config *MouseActionConfig) error

func (*Tab) Navigate

func (self *Tab) Navigate(url string) (*RpcMessage, error)

func (*Tab) PageSize added in v0.9.50

func (self *Tab) PageSize() (float64, float64, error)

func (*Tab) RPC

func (self *Tab) RPC(module string, method string, args map[string]interface{}) (*RpcMessage, error)

func (*Tab) RegisterEventHandler

func (self *Tab) RegisterEventHandler(eventGlob string, callback EventCallbackFunc) (string, error)

func (*Tab) RemoveWaiter

func (self *Tab) RemoveWaiter(id string)

func (*Tab) ResetMostRecentFrame

func (self *Tab) ResetMostRecentFrame()

func (*Tab) ResetNetworkRequests

func (self *Tab) ResetNetworkRequests()

func (*Tab) SendKey

func (self *Tab) SendKey(domKeyName string, config *KeyboardActionConfig) error

func (*Tab) StartScreencast

func (self *Tab) StartScreencast(quality int, width int, height int) error

func (*Tab) StopScreencast

func (self *Tab) StopScreencast() error

func (*Tab) WaitFor

func (self *Tab) WaitFor(eventGlob string, timeout time.Duration) (*Event, error)

type TabID

type TabID string

Jump to

Keyboard shortcuts

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