firefox

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: BSD-3-Clause Imports: 7 Imported by: 1

README

go-firefox

go-firefox is a set of tools to drive Firefox through the marionette protocol.

Documentation

Overview

Package firefox provides tools to script a marionetted Firefox.

Index

Constants

View Source
const (
	ByID    = marionette.ID
	ByQuery = marionette.CSS_SELECTOR
)

Variables

This section is empty.

Functions

func Attribute

func Attribute[T any](e *WebElement, name string) (T, error)

func Click

func Click(f Finder, by By, sel string) error

func InnerHTML

func InnerHTML(f Finder, by By, sel string) (string, error)

func Property

func Property[T any](e *WebElement, name string) (T, error)

func SendKeys

func SendKeys(f Finder, by By, sel, keys string) error

func TextContent

func TextContent(f Finder, by By, sel string) (string, error)

func WaitNotPresent

func WaitNotPresent(f Finder, by By, sel string) error

func WaitVisible

func WaitVisible(f Finder, by By, sel string) error

Types

type By

type By = marionette.By

type Client

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

Client is a Firefox client.

Client provides tools to script a marionetted Firefox instance.

func New

func New(opts ...Option) (*Client, error)

New creates a new Firefox client with the provided options.

func (*Client) Browser

func (cli *Client) Browser() *marionette.Client

Browser returns the marionette client connected to the underlying Firefox browser.

func (*Client) Close

func (cli *Client) Close() (err error)

Close closes the underlying Firefox browser and cleans everything up.

func (*Client) ExecuteScript

func (cli *Client) ExecuteScript(src Script, opts ...ScriptOption) (*Response, error)

func (*Client) FindElement

func (cli *Client) FindElement(by By, v string) (*WebElement, error)

FindElement finds an element using the indicated search strategy.

func (*Client) FindElements

func (cli *Client) FindElements(by By, v string) ([]*WebElement, error)

FindElements finds elements using the indicated search strategy.

func (*Client) Navigate

func (cli *Client) Navigate(v string) (*Response, error)

Navigate opens the url v

type Finder

type Finder = marionette.Finder

type Option

type Option func(c *Client) error

Option configures how a Firefox client should be customized.

func WithFirefoxProfile

func WithFirefoxProfile(dir string) Option

WithFirefoxProfile provides the path to the Firefox profile to use.

func WithHeadless

func WithHeadless(v bool) Option

WithHeadless instructs a Firefox client whether it should start with a GUI.

func WithKiosk

func WithKiosk(v bool) Option

WithKiosk instructs a Firefox client whether it should start in kiosk mode.

type Response

type Response = marionette.Response

type Script

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

func NewScript

func NewScript(src string, args ...any) Script

type ScriptOption

type ScriptOption func(scr *Script) error

func WithScriptNewSandbox

func WithScriptNewSandbox(v bool) ScriptOption

func WithScriptTimeout

func WithScriptTimeout(d time.Duration) ScriptOption

type WebElement

type WebElement = marionette.WebElement

func Nodes

func Nodes(f Finder, by By, sel string) ([]*WebElement, error)

Jump to

Keyboard shortcuts

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