cdp

package module
v0.0.0-...-fada95a Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2018 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidArgs     = errors.New("invalid args")
	ErrInvalidResponse = errors.New("invalid response")
)
View Source
var Browser = struct {
	Close      string
	GetVersion string
}{
	"Browser.close",
	"Browser.getVersion",
}
View Source
var DOM = struct {
	Enable               string
	Disable              string
	DescribeNode         string
	GetAttributes        string
	GetDocument          string
	GetFlattenedDocument string
	GetNodeForLocation   string
	GetOuterHTML         string
	PerformSearch        string
	QuerySelector        string
	QuerySelectorAll     string
	RemoveAttribute      string
	RemoveNode           string
	RequestChildNodes    string
	RequestNode          string
	ResolveNode          string
	SetAttributeValue    string
	SetAttributesAsText  string
	SetFileInputFiles    string
	SetNodeName          string
	SetNodeValue         string
	SetOuterHTML         string

	DocumentUpdated string
}{
	"DOM.enable",
	"DOM.disable",
	"DOM.describeNode",
	"DOM.getAttributes",
	"DOM.getDocument",
	"DOM.getFlattenedDocument",
	"DOM.getNodeForLocation",
	"DOM.getOuterHTML",
	"DOM.performSearch",
	"DOM.querySelector",
	"DOM.querySelectorAll",
	"DOM.removeAttribute",
	"DOM.removeNode",
	"DOM.requestChildNodes",
	"DOM.requestNode",
	"DOM.resolveNode",
	"DOM.setAttributeValue",
	"DOM.setAttributesAsText",
	"DOM.setFileInputFiles",
	"DOM.setNodeName",
	"DOM.setNodeValue",
	"DOM.setOuterHTML",

	"DOM.documentUpdated",
}
View Source
var Input = struct {
	DispatchKeyEvent           string
	DispatchMouseEvent         string
	DispatchTouchEvent         string
	EmulateTouchFromMouseEvent string
	SetIgnoreInputEvents       string
	SynthesizePinchGesture     string
	SynthesizeScrollGesture    string
	SynthesizeTapGesture       string
}{
	"Input.dispatchKeyEvent",
	"Input.dispatchMouseEvent",
	"Input.dispatchTouchEvent",
	"Input.emulateTouchFromMouseEvent",
	"Input.setIgnoreInputEvents",
	"Input.synthesizePinchGesture",
	"Input.synthesizeScrollGesture",
	"Input.synthesizeTapGesture",
}
View Source
var Page = struct {
	Enable            string
	Disable           string
	BringToFront      string
	CaptureScreenshot string
	Close             string
	DeleteCookie      string
	GetCookies        string
	Navigate          string
	PrintToPDF        string
	Reload            string
	StopLoading       string

	DomContentEventFired string
	FrameAttached        string
	FrameDetached        string
	FrameNavigated       string
	FrameStartedLoading  string
	FrameStoppedLoading  string
	LifecycleEvent       string
	LoadEventFired       string
}{
	"Page.enable",
	"Page.disable",
	"Page.bringToFront",
	"Page.captureScreenshot",
	"Page.close",
	"Page.deleteCookie",
	"Page.getCookies",
	"Page.navigate",
	"Page.printToPDF",
	"Page.reload",
	"Page.stopLoading",

	"Page.domContentEventFired",
	"Page.frameAttached",
	"Page.frameDetached",
	"Page.frameNavigated",
	"Page.frameStartedLoading",
	"Page.frameStoppedLoading",
	"Page.lifecycleEvent",
	"Page.loadEventFired",
}
View Source
var Runtime = struct {
	Enable        string
	Disable       string
	CompileScript string
	Evaluate      string
	RunScript     string
}{
	"Runtime.enable",
	"Runtime.disable",
	"Runtime.compileScript",
	"Runtime.evaluate",
	"Runtime.runScript",
}

Functions

This section is empty.

Types

type Action

type Action interface {
	Method() string

	Params() Params
}

type Chrome

type Chrome string

func AttachToChrome

func AttachToChrome(host string, port int) (Chrome, error)

func LaunchChrome

func LaunchChrome(bin string, args ...string) (Chrome, error)

func (Chrome) NewTab

func (c Chrome) NewTab() (*Tab, error)

type EvaluateAction

type EvaluateAction interface {
	Action

	Expressions() []string

	Handle(Result) error
}

type Message

type Message struct {
	// 请求的ID,响应中会带有相同的ID,
	// 事件通知没有该字段
	Id int32 `json:"id,omitempty"`

	// 请求、响应和事件通知都有该字段
	Method string `json:"method,omitempty"`

	// 请求的参数(可选)、事件通知的数据(可选),
	// 响应没有该字段
	Params Params `json:"params,omitempty"`

	// 响应数据(请求和事件通知没有该字段)
	Result Result `json:"result,omitempty"`
	// contains filtered or unexported fields
}

type Params

type Params map[string]interface{}

type Result

type Result map[string]interface{}

type SimpleAction

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

func NewAction

func NewAction(method string, params ...Params) *SimpleAction

func (*SimpleAction) Method

func (sa *SimpleAction) Method() string

func (*SimpleAction) Params

func (sa *SimpleAction) Params() Params

type SimpleEvaluateAction

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

func NewEvaluateAction

func NewEvaluateAction(expression string, handler func(Result) error) *SimpleEvaluateAction

func (*SimpleEvaluateAction) Expressions

func (sea *SimpleEvaluateAction) Expressions() []string

func (*SimpleEvaluateAction) Handle

func (sea *SimpleEvaluateAction) Handle(result Result) error

func (*SimpleEvaluateAction) Method

func (sea *SimpleEvaluateAction) Method() string

func (*SimpleEvaluateAction) Params

func (sea *SimpleEvaluateAction) Params() Params

type Tab

type Tab struct {

	// WebSocket上读取到的数据经过处理后发送给该channel
	C chan *Message
	// contains filtered or unexported fields
}

func (*Tab) Activate

func (t *Tab) Activate()

func (*Tab) Call

func (t *Tab) Call(method string, params ...Params) *Message

func (*Tab) CallAsync

func (t *Tab) CallAsync(method string, params ...Params)

func (*Tab) Close

func (t *Tab) Close()

func (*Tab) Subscribe

func (t *Tab) Subscribe(method string)

func (*Tab) Unsubscribe

func (t *Tab) Unsubscribe(method string)

type Task

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

func NewTask

func NewTask(c Chrome) *Task

func (*Task) Action

func (t *Task) Action(action Action) *Task

func (*Task) Run

func (t *Task) Run(ctx context.Context)

func (*Task) Sleep

func (t *Task) Sleep(duration time.Duration) *Task

func (*Task) WaitFor

func (t *Task) WaitFor(event string) *Task

Jump to

Keyboard shortcuts

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