chrome_ns

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RevisionDefault for chromium
	RevisionDefault = 1131657

	// RevisionPlaywright for arm linux
	RevisionPlaywright = 1080
)
View Source
const (
	DEFAULT_SINGLE_ACTION_TIMEOUT = 15 * time.Second

	LOG_SRC = "chrome"
)
View Source
const (
	BROWSER_PROXY_PORT = 12750
	BROWSER_PROXY_ADDR = "127.0.0.1:12750"

	//After a browser instance is created it navigates to this URL.
	//The request is intercepted by the proxy, no server is listening on this port.
	//The hostname should not be changed because using the loopback allows to check that
	//requests to the loopback do not bypass the proxy.
	CHROME_INSTANCE_REGISTRATION_URL_PREFIX = "https://127.0.0.1:9999/register-browser-instance/"

	BROWSER_PROXY_SRC_NAME = "/browser-proxy"
)
View Source
const (
	HANDLE_ID_HEADER = "X-Browser-Handle"
)

Variables

View Source
var (
	BROWSER_BINPATH   = ""
	BROWSER_INSTALLED = false //true if a browser not downloaded by Inox is present
)
View Source
var (
	HANDLE_PROPNAMES = []string{"nav", "wait_visible", "click", "screenshot_page", "html_node", "close"}

	ErrBrowserAutomationNotAllowed = errors.New("browser automation is not allowed")
)
View Source
var DefaultBrowserDir = filepath.Join(map[string]string{
	"linux": filepath.Join(os.Getenv("HOME"), ".cache"),
}[runtime.GOOS], "inox", "browser")

DefaultBrowserDir for downloaded browser. For unix is "$HOME/.cache/inox/browser",

View Source
var (
	ErrPageFailedToLoad = errors.New("page failed to load")
)
View Source
var (
	ErrProxyAlreadyStarted = errors.New("browser proxy already started")
)

Functions

func AllowBrowserAutomation

func AllowBrowserAutomation()

func DisallowBrowserAutomation

func DisallowBrowserAutomation()

func DownloadBrowser

func DownloadBrowser(ctx context.Context, logger zerolog.Logger) (execPath string, finalErr error)

DownloadBrowser downloads a chrome browser, no permissions are checked.

func HostGoogle

func HostGoogle(revision int) string

HostGoogle to download browser

func HostNPM

func HostNPM(revision int) string

HostNPM to download browser

func HostPlaywright

func HostPlaywright(revision int) string

HostPlaywright to download browser

func IsBrowserAutomationAllowed

func IsBrowserAutomationAllowed() bool

func LookPath

func LookPath() (found string, has bool)

LookPath searches for the browser executable from often used paths on current operating system.

func NewChromeNamespace

func NewChromeNamespace() *core.Namespace

func SetBrowserBinPath

func SetBrowserBinPath(val string)

func SetBrowserBinPathToInstalledOrCachedBrowser

func SetBrowserBinPathToInstalledOrCachedBrowser() bool

func StartSharedProxy

func StartSharedProxy(ctx *core.Context) error

StartSharedProxy starts an HTTP proxy in another goroutine, the proxy is used by all browser instances controlled by the current package.

func Validate

func Validate(binpath string) error

Validates checks there is a valid chrome binary at binpath.

Types

type Handle

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

func NewHandle

func NewHandle(ctx *core.Context) (*Handle, error)

func (*Handle) Click

func (h *Handle) Click(ctx *core.Context, s core.String) error

func (*Handle) Close

func (h *Handle) Close(ctx *core.Context)

func (*Handle) Equal

func (h *Handle) Equal(ctc *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, depth int) bool

func (*Handle) GetGoMethod

func (h *Handle) GetGoMethod(name string) (*core.GoFunction, bool)

func (*Handle) HtmlNode

func (h *Handle) HtmlNode(ctx *core.Context, sel core.String) (*html_ns.HTMLNode, error)

func (*Handle) IsMutable

func (h *Handle) IsMutable() bool

func (*Handle) Nav

func (h *Handle) Nav(ctx *core.Context, u core.URL) error

func (*Handle) PrettyPrint

func (h *Handle) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, parentIndentCount int)

func (*Handle) Prop

func (h *Handle) Prop(ctx *core.Context, name string) core.Value

func (*Handle) PropertyNames

func (h *Handle) PropertyNames(ctx *core.Context) []string

func (*Handle) Screenshot

func (h *Handle) Screenshot(ctx *core.Context, sel core.String) (*core.ByteSlice, error)

func (*Handle) ScreenshotPage

func (h *Handle) ScreenshotPage(ctx *core.Context) (*core.ByteSlice, error)

func (*Handle) SetProp

func (*Handle) SetProp(ctx *core.Context, name string, value core.Value) error

func (*Handle) ToSymbolicValue

func (h *Handle) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)

func (*Handle) WaitVisible

func (h *Handle) WaitVisible(ctx *core.Context, s core.String) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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