page

package
v0.9.22 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2018 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Commands for inspecting and manipulating the current DOM document and browser viewport.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commands

type Commands struct {
	friendscript.Module
	// contains filtered or unexported fields
}

func New

func New(browser *browser.Browser, scopeable utils.Scopeable) *Commands

func (*Commands) Pdf

func (self *Commands) Pdf(destination interface{}, args *PdfArgs) error

Render the current page as a PDF document, writing it to the given filename or writable destination object.

func (*Commands) Remove

func (self *Commands) Remove(selector browser.Selector, args *RemoveArgs) (int, error)

Remove all occurrences of the element(s) matching the given selector.

func (*Commands) Screenshot

func (self *Commands) Screenshot(destination interface{}, args *ScreenshotArgs) (*ScreenshotResponse, error)

Render the current page as a PNG or JPEG image, writing it to the given filename or writable destination object.

If the filename is the string `"temporary"`, a file will be created in the system's temporary area (e.g.: `/tmp`) and the screenshot will be written there. It is the caller's responsibility to remove the temporary file if desired. The temporary file path is available in the return object's `path` parameter.

func (*Commands) Source

func (self *Commands) Source(selector browser.Selector) (string, error)

Return the source for the given element, or for the whole page.

func (*Commands) Text

func (self *Commands) Text(selector browser.Selector) (string, error)

Return the text content for the given element, or for the whole page.

type PdfArgs

type PdfArgs struct {
	// Whether the given destination should be automatically closed for writing after the
	// PDF is written.
	Autoclose bool `json:"autoclose" default:"true"`
}

type RemoveArgs

type RemoveArgs struct {
	Parent browser.Selector `json:"parent"`
}

type ScreenshotArgs

type ScreenshotArgs struct {
	// If specified, the screenshot will attempt to capture just the matching element.
	Selector browser.Selector `json:"selector,omitempty"`

	// Determines how to handle multiple elements that are matched by Selector.
	// May be "tallest" or "first".
	Use string `json:"use,omitempty" default:"tallest"`

	Width  int `json:"width"`
	Height int `json:"height"`
	X      int `json:"x" default:"-1"`
	Y      int `json:"y" default:"-1"`

	// The output image format of the screenshot.  May be "png" or "jpeg".
	Format string `json:"format" default:"png"`

	// The quality of the image used during encoding.  Only applies to "jpeg" format.
	Quality int `json:"quality"`

	// Whether the given destination should be automatically closed for writing after the
	// screenshot is written.
	Autoclose bool `json:"autoclose" default:"true"`

	// Automatically resize the screen to the width and height.
	Autoresize bool `json:"autoresize" default:"true"`
}

type ScreenshotResponse

type ScreenshotResponse struct {
	// Details about the element that matched the given selector (if any).
	Element *browser.Element `json:"element,omitempty"`

	// The width of the screenshot (in pixels).
	Width int `json:"width"`

	// The height of the screenshot (in pixels).
	Height int `json:"height"`

	// The X position (relative to the viewport) the screenshot was taken at.
	X int `json:"x"`

	// The Y position (relative to the viewport) the screenshot was taken at.
	Y int `json:"y"`

	// The filesystem path that the screenshot was written to.
	Path string `json:"path,omitempty"`

	// The size of the screenshot (in bytes).
	Size int64 `json:"size,omitempty"`
}

Jump to

Keyboard shortcuts

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