Documentation ¶
Index ¶
- Variables
- type Browser
- type Page
- func (p *Page) CleanUp()
- func (p *Page) ClickNavigate(selector string, timeout time.Duration) error
- func (p *Page) Dialogs() []*proto.PageJavascriptDialogOpening
- func (p *Page) HasElement(selector string) (*rod.Element, error)
- func (p *Page) SaveDialog(d *proto.PageJavascriptDialogOpening)
- func (p *Page) TryInput(selector, text string) error
- func (p *Page) TryNavigate(url string, predicate Predicate[*Page], backoff time.Duration) error
- func (p *Page) WaitJSObject(objName string) error
- func (p *Page) WaitJSObjectFor(objName string, until time.Duration) error
- func (p *Page) WaitVisibleElement(selector string) (el *rod.Element, err error)
- type PagePool
- type Predicate
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Browser ¶
Browser is a wrapper that embeds rod.Browser instance
func NewBrowser ¶
NewBrowser returns new browser with given pool size. Note that the pagePoolSize cannot be changed after the initialization.
func NewBrowserWithProxy ¶
NewBrowserWithProxy returns new browser with given pool size and proxy. Note that the pagePoolSize and proxy cannot be changed after the initialization.
func (*Browser) CleanUp ¶
func (b *Browser) CleanUp()
CleanUp wait then wipe all resources under this browser instance.
func (*Browser) GetPage ¶
GetPage return a page from this Browser's page pool. Note that it will block until a page is available from the pool. It is required for a caller to put back the page to the pool via PutPage function.
type Page ¶
func (*Page) CleanUp ¶
func (p *Page) CleanUp()
CleanUp calls page done once and only once, signalling Browser such that the page is actually closed.
func (*Page) ClickNavigate ¶
ClickNavigate clicks an element that is matching the given selector as criteria.
func (*Page) Dialogs ¶
func (p *Page) Dialogs() []*proto.PageJavascriptDialogOpening
Dialogs returns history of current page's dialogs.
func (*Page) HasElement ¶
HasElement checks if any element matching the given selector. If exists, will return an element with no error, or vise versa.
func (*Page) SaveDialog ¶
func (p *Page) SaveDialog(d *proto.PageJavascriptDialogOpening)
SaveDialog appends given proto.PageJavascriptDialogOpening to current page's dialog history.
func (*Page) TryInput ¶
TryInput is a conjunction of Page.WaitVisibleElement and *rod.Element's Input function. It will propagate any error from subsequent actions by immediately returning that non-nil error. It will return error as nil if the action has been successfully executed.
func (*Page) TryNavigate ¶
TryNavigate is a safe-guarding method of navigation with indefinite retry. Need of this navigation arose when navigation is succeeded with 2XX with blank HTML response. Logic to determine whether the navigation succeeded or not depends on Predicate for given Page.
func (*Page) WaitJSObject ¶
func (*Page) WaitJSObjectFor ¶
WaitJSObjectFor enforces this page to await for specified JavaScript Object to be loaded to given page, for specified time duration. It will wait for the item by each depth for the name by dot delimiter.
func (*Page) WaitVisibleElement ¶
WaitVisibleElement is a shortcut for search and wait for element to be visible (i.e. interact-ready) Any failure from child action will be propagated. Will return an element with no error on success, otherwise will return nil with error for failing reason.