Documentation
¶
Index ¶
- Variables
- func Click(_ context.Context, args ...core.Value) (core.Value, error)
- func ClickAll(_ context.Context, args ...core.Value) (core.Value, error)
- func Document(ctx context.Context, args ...core.Value) (core.Value, error)
- func DocumentParse(ctx context.Context, args ...core.Value) (core.Value, error)
- func Element(_ context.Context, args ...core.Value) (core.Value, error)
- func Elements(_ context.Context, args ...core.Value) (core.Value, error)
- func ElementsCount(_ context.Context, args ...core.Value) (core.Value, error)
- func InnerHTML(_ context.Context, args ...core.Value) (core.Value, error)
- func InnerHTMLAll(_ context.Context, args ...core.Value) (core.Value, error)
- func InnerText(_ context.Context, args ...core.Value) (core.Value, error)
- func InnerTextAll(_ context.Context, args ...core.Value) (core.Value, error)
- func Input(_ context.Context, args ...core.Value) (core.Value, error)
- func Navigate(_ context.Context, args ...core.Value) (core.Value, error)
- func NavigateBack(_ context.Context, args ...core.Value) (core.Value, error)
- func NavigateForward(_ context.Context, args ...core.Value) (core.Value, error)
- func NewLib() map[string]core.Function
- func PDF(ctx context.Context, args ...core.Value) (core.Value, error)
- func Screenshot(ctx context.Context, args ...core.Value) (core.Value, error)
- func ValidateDocument(ctx context.Context, value core.Value) (core.Value, error)
- func ValidatePageRanges(pageRanges string) (bool, error)
- func WaitClass(_ context.Context, args ...core.Value) (core.Value, error)
- func WaitClassAll(_ context.Context, args ...core.Value) (core.Value, error)
- func WaitElement(_ context.Context, args ...core.Value) (core.Value, error)
- func WaitNavigation(_ context.Context, args ...core.Value) (core.Value, error)
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotDynamic = errors.New("expected dynamic document or element")
)
Functions ¶
func Click ¶
* Dispatches click event on a given element * @param source (Document | Element) - Event source. * @param selector (String, optional) - Optional selector. Only used when a document instance is passed.
func ClickAll ¶
* Dispatches click event on all matched element * @param source (Document) - Document. * @param selector (String) - Selector. * @returns (Boolean) - Returns true if matched at least one element.
func Document ¶
* Loads a document by a given url. * By default, loads a document by http call - resulted document does not support any interactions. * If passed "true" as a second argument, headless browser is used for loading the document which support interactions. * @param url (String) - Target url string. If passed "about:blank" for dynamic document - it will open an empty page. * @param dynamic (Boolean) - Optional boolean value indicating whether to use dynamic document. * @returns (HTMLDocument) - Returns loaded HTML document.
func DocumentParse ¶
* Parses a given HTML string and returns a HTML document. * Returned HTML document is always static. * @param html (String) - Target HTML string. * @returns (HTMLDocument) - Parsed HTML static document.
func Element ¶
* Finds an element by a given CSS selector. * Returns NONE if element not found. * @param docOrEl (HTMLDocument|HTMLElement) - Parent document or element. * @param selector (String) - CSS selector. * @returns (HTMLElement | None) - Returns an HTMLElement if found, otherwise NONE.
func Elements ¶
* Finds HTML elements by a given CSS selector. * Returns an empty array if element not found. * @param docOrEl (HTMLDocument|HTMLElement) - Parent document or element. * @param selector (String) - CSS selector. * @returns (Array) - Returns an array of found HTML element.
func ElementsCount ¶
* Returns a number of found HTML elements by a given CSS selector. * Returns an empty array if element not found. * @param docOrEl (HTMLDocument|HTMLElement) - Parent document or element. * @param selector (String) - CSS selector. * @returns (Int) - A number of found HTML elements by a given CSS selector.
func InnerHTML ¶
* Returns inner HTML string of a matched element * @param doc (Document|Element) - Parent document or element. * @param selector (String) - String of CSS selector. * @returns (String) - Inner HTML string if an element found, otherwise empty string.
func InnerHTMLAll ¶
* Returns an array of inner HTML strings of matched elements. * @param doc (HTMLDocument|HTMLElement) - Parent document or element. * @param selector (String) - String of CSS selector. * @returns (String) - An array of inner HTML strings if any element found, otherwise empty array.
func InnerText ¶
* Returns inner text of a matched element * @param doc (HTMLDocument|HTMLElement) - Parent document or element. * @param selector (String) - String of CSS selector. * @returns (String) - Inner text if an element found, otherwise empty string.
func InnerTextAll ¶
* Returns an array of inner text of matched elements. * @param doc (HTMLDocument|HTMLElement) - Parent document or element. * @param selector (String) - String of CSS selector. * @returns (String) - An array of inner text if any element found, otherwise empty array.
func Input ¶
* Types a value to an underlying input element. * @param source (Document | Element) - Event target. * @param valueOrSelector (String) - Selector or a value. * @param value (String) - Target value. * @param delay (Int, optional) - Waits delay milliseconds between keystrokes * @returns (Boolean) - Returns true if an element was found.
func Navigate ¶
* Navigates a document to a new resource. * The operation blocks the execution until the page gets loaded. * Which means there is no need in WAIT_NAVIGATION function. * @param doc (Document) - Target document. * @param url (String) - Target url to navigate. * @param timeout (Int, optional) - Optional timeout. Default is 5000.
func NavigateBack ¶
* Navigates a document back within its navigation history. * The operation blocks the execution until the page gets loaded. * If the history is empty, the function returns FALSE. * @param doc (Document) - Target document. * @param entry (Int, optional) - Optional value indicating how many pages to skip. Default 1. * @param timeout (Int, optional) - Optional timeout. Default is 5000. * @returns (Boolean) - Returns TRUE if history exists and the operation succeeded, otherwise FALSE.
func NavigateForward ¶
* Navigates a document forward within its navigation history. * The operation blocks the execution until the page gets loaded. * If the history is empty, the function returns FALSE. * @param doc (Document) - Target document. * @param entry (Int, optional) - Optional value indicating how many pages to skip. Default 1. * @param timeout (Int, optional) - Optional timeout. Default is 5000. * @returns (Boolean) - Returns TRUE if history exists and the operation succeeded, otherwise FALSE.
func PDF ¶
* Print a PDF of the current page. * @param source (Document) - Document. * @param params (Object) - Optional, An object containing the following properties : * Landscape (Bool) - Paper orientation. Defaults to false. * DisplayHeaderFooter (Bool) - Display header and footer. Defaults to false. * PrintBackground (Bool) - Print background graphics. Defaults to false. * Scale (Float64) - Scale of the webpage rendering. Defaults to 1. * PaperWidth (Float64) - Paper width in inches. Defaults to 8.5 inches. * PaperHeight (Float64) - Paper height in inches. Defaults to 11 inches. * MarginTop (Float64) - Top margin in inches. Defaults to 1cm (~0.4 inches). * MarginBottom (Float64) - Bottom margin in inches. Defaults to 1cm (~0.4 inches). * MarginLeft (Float64) - Left margin in inches. Defaults to 1cm (~0.4 inches). * MarginRight (Float64) - Right margin in inches. Defaults to 1cm (~0.4 inches). * PageRanges (String) - Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages. * IgnoreInvalidPageRanges (Bool) - to silently ignore invalid but successfully parsed page ranges, such as '3-2'. Defaults to false. * HeaderTemplate (String) - HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: - `date`: formatted print date - `title`: document title - `url`: document location - `pageNumber`: current page number - `totalPages`: total pages in the document For example, `<span class=title></span>` would generate span containing the title. * FooterTemplate (String) - HTML template for the print footer. Should use the same format as the `headerTemplate`. * PreferCSSPageSize (Bool) - Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size. * * @returns data (Binary) - Returns a base64 encoded string in binary format.
func Screenshot ¶
* Take a screenshot of the current page. * @param source (Document) - Document. * @param params (Object) - Optional, An object containing the following properties : * x (Float|Int) - Optional, X position of the viewport. * x (Float|Int) - Optional,Y position of the viewport. * width (Float|Int) - Optional, Width of the viewport. * height (Float|Int) - Optional, Height of the viewport. * format (String) - Optional, Either "jpeg" or "png". * quality (Int) - Optional, Quality, in [0, 100], only for jpeg format. * @returns data (Binary) - Returns a base64 encoded string in binary format.
func ValidateDocument ¶
func ValidatePageRanges ¶
func WaitClass ¶
* Waits for a class to appear on a given element. * Stops the execution until the navigation ends or operation times out. * @param docOrEl (HTMLDocument|HTMLElement) - Target document or element. * @param selectorOrClass (String) - If document is passed, this param must represent an element selector. * Otherwise target class. * @param classOrTimeout (String|Int, optional) - If document is passed, this param must represent target class name. * Otherwise timeout. * @param timeout (Int, optional) - If document is passed, this param must represent timeout. * Otherwise not passed.
func WaitClassAll ¶
* Waits for a class to appear on all matched elements. * Stops the execution until the navigation ends or operation times out. * @param doc (HTMLDocument) - Parent document. * @param selector (String) - String of CSS selector. * @param class (String) - String of target CSS class. * @param timeout (Int, optional) - Optional timeout.
func WaitElement ¶
* Waits for element to appear in the DOM. * Stops the execution until it finds an element or operation times out. * @param doc (HTMLDocument) - Dynamic HTMLDocument. * @param selector (String) - Target element's selector. * @param timeout (Int, optional) - Optional timeout. Default 5000 ms.
func WaitNavigation ¶
* Waits for document to navigate to a new url. * Stops the execution until the navigation ends or operation times out. * @param doc (HTMLDocument) - Dynamic HTMLDocument. * @param timeout (Int, optional) - Optional timeout. Default 5000 ms.
Types ¶
This section is empty.