1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-14 11:23:02 +02:00

Updated comments

This commit is contained in:
Tim Voronov 2019-09-07 14:03:17 -04:00
parent 45bab19c0a
commit 012029f8d9
47 changed files with 67 additions and 51 deletions

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
// AttributeGet gets single or more attribute(s) of a given element.
// ATTR_GET gets single or more attribute(s) of a given element.
// @param el (HTMLElement) - Target element.
// @param names (...String) - Attribute name(s).
// @returns Object - Key-value pairs of attribute values.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// AttributeRemove removes single or more attribute(s) of a given element.
// ATTR_REMOVE removes single or more attribute(s) of a given element.
// @param el (HTMLElement) - Target element.
// @param names (...String) - Attribute name(s).
func AttributeRemove(ctx context.Context, args ...core.Value) (core.Value, error) {

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// AttributeSet sets or updates a single or more attribute(s) of a given element.
// ATTR_SET sets or updates a single or more attribute(s) of a given element.
// @param el (HTMLElement) - Target element.
// @param nameOrObj (String | Object) - Attribute name or an object representing a key-value pair of attributes.
// @param value (String) - If a second parameter is a string value, this parameter represent an attribute value.

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
// InputClear clears a value from an underlying input element.
// INPUT_CLEAR clears a value from an underlying input element.
// @param source (HTMLPage | HTMLDocument | HTMLElement) - Event target.
// @param selector (String, options) - Selector.
func InputClear(ctx context.Context, args ...core.Value) (core.Value, error) {

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// Click dispatches click event on a given element
// CLICK dispatches click event on a given element
// @param source (Open | GetElement) - Event source.
// @param selectorOrCount (String | Int, optional) - Optional selector or count of clicks.
// @param count (Int, optional) - Optional count of clicks.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// ClickAll dispatches click event on all matched element
// CLICK_ALL dispatches click event on all matched element
// @param source (Open) - Open.
// @param selector (String) - Selector.
// @param count (Int, optional) - Optional count of clicks.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// CookieSet gets a cookie from a given page by name.
// COOKIE_DEL gets a cookie from a given page by name.
// @param page (HTMLPage) - Target page.
// @param cookie (...HTTPCookie|String) - Cookie or cookie name to delete.
func CookieDel(ctx context.Context, args ...core.Value) (core.Value, error) {

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// CookieSet gets a cookie from a given page by name.
// COOKIE_GET gets a cookie from a given page by name.
// @param page (HTMLPage) - Target page.
// @param name (String) - Cookie or cookie name to delete.
func CookieGet(ctx context.Context, args ...core.Value) (core.Value, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
// CookieSet sets cookies to a given page
// COOKIE_SET sets cookies to a given page
// @param page (HTMLPage) - Target page.
// @param cookie... (HTTPCookie) - Target cookies.
func CookieSet(ctx context.Context, args ...core.Value) (core.Value, error) {

View File

@ -18,7 +18,7 @@ type PageLoadParams struct {
Timeout time.Duration
}
// Open opens an HTML page by a given url.
// DOCUMENT opens an HTML page by a given url.
// By default, loads a page by http call - resulted page does not support any interactions.
// @param params (Object) - Optional, An object containing the following properties :
// driver (String) - Optional, driver name.

View File

@ -10,7 +10,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// Download a resource from the given GetURL.
// DOWNLOAD downloads a resource from the given GetURL.
// @param GetURL (String) - GetURL to download.
// @returns data (Binary) - Returns a base64 encoded string in binary format.
func Download(_ context.Context, args ...core.Value) (core.Value, error) {

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// GetElement finds an element by a given CSS selector.
// 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.

View File

@ -7,7 +7,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
// ElementExists returns a boolean value indicating whether there is an element matched by selector.
// ELEMENT_EXISTS returns a boolean value indicating whether there is an element matched by selector.
// @param docOrEl (HTMLDocument|HTMLNode) - Parent document or element.
// @param selector (String) - CSS selector.
// @returns (Boolean) - A boolean value indicating whether there is an element matched by selector.

View File

@ -7,7 +7,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
// Elements finds HTML elements by a given CSS selector.
// ELEMENTS finds HTML elements by a given CSS selector.
// Returns an empty array if element not found.
// @param docOrEl (HTMLDocument|HTMLNode) - Parent document or element.
// @param selector (String) - CSS selector.

View File

@ -7,7 +7,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
// ElementsCount returns a number of found HTML elements by a given CSS selector.
// ELEMENTS_COUNT returns a number of found HTML elements by a given CSS selector.
// Returns an empty array if element not found.
// @param docOrEl (HTMLDocument|HTMLNode) - Parent document or element.
// @param selector (String) - CSS selector.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// GetInnerHTML Returns inner HTML string of a given or matched by CSS selector element
// INNER_HTML returns inner HTML string of a given or matched by CSS selector element
// @param doc (Open|GetElement) - Parent document or element.
// @param selector (String, optional) - String of CSS selector.
// @returns (String) - Inner HTML string if an element found, otherwise empty string.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// GetInnerHTMLAll returns an array of inner HTML strings of matched elements.
// INNER_HTML_ALL 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.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// GetInnerText returns inner text string of a given or matched by CSS selector element
// INNER_TEXT returns inner text string of a given or matched by CSS selector element
// @param doc (HTMLDocument|HTMLElement) - Parent document or element.
// @param selector (String, optional) - String of CSS selector.
// @returns (String) - Inner text if an element found, otherwise empty string.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// GetInnerTextAll returns an array of inner text of matched elements.
// INNER_TEXT_ALL 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.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// Hover fetches an element with selector, scrolls it into view if needed, and then uses page.mouse to hover over the center of the element.
// HOVER fetches an element with selector, scrolls it into view if needed, and then uses page.mouse to hover over the center of the element.
// If there's no element matching selector, the method returns an error.
// @param docOrEl (HTMLDocument|HTMLElement) - Target document or element.
// @param selector (String, options) - If document is passed, this param must represent an element selector.

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// Input types a value to an underlying input element.
// INPUT types a value to an underlying input element.
// @param source (HTMLPage | HTMLDocument | HTMLElement) - Event target.
// @param valueOrSelector (String) - Selector or a value.
// @param value (String) - Target value.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// MouseMoveXY moves mouse by given coordinates.
// MOUSE moves mouse by given coordinates.
// @param doc (HTMLDocument) - HTML document.
// @param x (Int|Float) - X coordinate.
// @param y (Int|Float) - Y coordinate.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// Navigate navigates a given page to a new resource.
// NAVIGATE navigates a given page 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 page (HTMLPage) - Target page.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// NavigateBack navigates a given page back within its navigation history.
// NAVIGATE_BACK navigates a given page 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 page (HTMLPage) - Target page.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// NavigateForward navigates a given page forward within its navigation history.
// NAVIGATE_FORWARD navigates a given page 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 page (HTMLPage) - Target page.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// Pagination creates an iterator that goes through pages using CSS selector.
// PAGINATION creates an iterator that goes through pages using CSS selector.
// The iterator starts from the current page i.e. it does not change the page on 1st iteration.
// That allows you to keep scraping logic inside FOR loop.
// @param doc (Open) - Target document.

View File

@ -21,7 +21,7 @@ func ValidatePageRanges(pageRanges string) (bool, error) {
return match, nil
}
// PDF print a PDF of the current page.
// PDF prints a PDF of the current page.
// @param target (HTMLPage|String) - Target page or url.
// @param params (Object) - Optional, An object containing the following properties :
// Landscape (Bool) - Paper orientation. Defaults to false.

View File

@ -10,7 +10,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// Screenshot takes a screenshot of a given page.
// SCREENSHOT takes a screenshot of a given page.
// @param target (HTMLPage|String) - Target page or url.
// @param params (Object) - Optional, An object containing the following properties :
// x (Float|Int) - Optional, X position of the viewport.

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
// ScrollTop scrolls the document's window to its bottom.
// SCROLL_BOTTOM scrolls the document's window to its bottom.
// @param doc (HTMLDocument) - Target document.
func ScrollBottom(ctx context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// ScrollInto scrolls an element on.
// SCROLL_ELEMENT scrolls an element on.
// @param docOrEl (HTMLDocument|HTMLElement) - Target document or element.
// @param selector (String, options) - If document is passed, this param must represent an element selector.
func ScrollInto(ctx context.Context, args ...core.Value) (core.Value, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
// ScrollTop scrolls the document's window to its top.
// SCROLL_TOP scrolls the document's window to its top.
// @param doc (HTMLDocument) - Target document.
func ScrollTop(ctx context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// ScrollXY scrolls by given coordinates.
// SCROLL scrolls by given coordinates.
// @param doc (HTMLDocument) - HTML document.
// @param x (Int|Float) - X coordinate.
// @param y (Int|Float) - Y coordinate.

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
// Select selects a value from an underlying select element.
// SELECT selects a value from an underlying select element.
// @param source (Open | GetElement) - Event target.
// @param valueOrSelector (String | Array<String>) - Selector or a an array of strings as a value.
// @param value (Array<String) - Target value. Optional.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// SetInnerHTML sets inner HTML string to a given or matched by CSS selector element
// INNER_HTML_SET sets inner HTML string to a given or matched by CSS selector element
// @param doc (Open|GetElement) - Parent document or element.
// @param selector (String, optional) - String of CSS selector.
// @param innerHTML (String) - String of inner HTML.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// SetInnerText sets inner text string to a given or matched by CSS selector element
// INNER_TEXT_SET sets inner text string to a given or matched by CSS selector element
// @param doc (Open|GetElement) - Parent document or element.
// @param selector (String, optional) - String of CSS selector.
// @param innerText (String) - String of inner text.

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
// StyleGet gets single or more style attribute value(s) of a given element.
// STYLE_GET gets single or more style attribute value(s) of a given element.
// @param el (HTMLElement) - Target element.
// @param names (...String) - Style name(s).
// @returns Object - Key-value pairs of style values.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// StyleRemove removes single or more style attribute value(s) of a given element.
// STYLE_REMOVE removes single or more style attribute value(s) of a given element.
// @param el (HTMLElement) - Target element.
// @param names (...String) - Style name(s).
func StyleRemove(ctx context.Context, args ...core.Value) (core.Value, error) {

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// StyleSet sets or updates a single or more style attribute value of a given element.
// STYLE_SET sets or updates a single or more style attribute value of a given element.
// @param el (HTMLElement) - Target element.
// @param nameOrObj (String | Object) - Style name or an object representing a key-value pair of attributes.
// @param value (String) - If a second parameter is a string value, this parameter represent a style value.

View File

@ -9,10 +9,22 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// WAIT_ATTR waits until a target attribute's value appears
// @param node (HTMLPage | HTMLDocument | HTMLElement) - Parent document.
// @param attrNameOrSelector (String) - String of an attr name or CSS selector.
// @param attrValueOrAttrName (String | Any) - Attr value or name.
// @param attrValueOrTimeout (Any | Int, optional) - Attr value or an optional timeout.
// @param timeout (Int, optional) - Optional timeout.
func WaitAttribute(ctx context.Context, args ...core.Value) (core.Value, error) {
return waitAttributeWhen(ctx, args, drivers.WaitEventPresence)
}
// WAIT_NO_ATTR waits until a target attribute's value disappears
// @param node (HTMLPage | HTMLDocument | HTMLElement) - Parent document.
// @param attrNameOrSelector (String) - String of an attr name or CSS selector.
// @param attrValueOrAttrName (String | Any) - Attr value or name.
// @param attrValueOrTimeout (Any | Int, optional) - Attr value or an optional timeout.
// @param timeout (Int, optional) - Optional timeout.
func WaitNoAttribute(ctx context.Context, args ...core.Value) (core.Value, error) {
return waitAttributeWhen(ctx, args, drivers.WaitEventAbsence)
}

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// WaitClassAll waits for a class to appear on all matched elements.
// WAIT_ATTR_ALL waits for an attribute to appear on all matched elements with a given value.
// Stops the execution until the navigation ends or operation times out.
// @param doc (HTMLDocument) - Parent document.
// @param selector (String) - String of CSS selector.
@ -19,7 +19,7 @@ func WaitAttributeAll(ctx context.Context, args ...core.Value) (core.Value, erro
return waitAttributeAllWhen(ctx, args, drivers.WaitEventPresence)
}
// WaitClassAll waits for a class to disappear on all matched elements.
// WAIT_NO_ATTR_ALL waits for an attribute to disappear on all matched elements by a given value.
// Stops the execution until the navigation ends or operation times out.
// @param doc (HTMLDocument) - Parent document.
// @param selector (String) - String of CSS selector.

View File

@ -9,9 +9,9 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// WaitClass waits for a class to appear on a given element.
// WAIT_CLASS 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 node (HTMLPage | HTMLDocument | HTMLElement) - Target node.
// @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.
@ -22,9 +22,9 @@ func WaitClass(ctx context.Context, args ...core.Value) (core.Value, error) {
return waitClassWhen(ctx, args, drivers.WaitEventPresence)
}
// WaitClass waits for a class to disappear on a given element.
// WAIT_NO_CLASS waits for a class to disappear on a given element.
// Stops the execution until the navigation ends or operation times out.
// @param docOrEl (HTMLDocument|HTMLElement) - Target document or element.
// @param node (HTMLPage | HTMLDocument | HTMLElement) - Target node.
// @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.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// WaitClassAll waits for a class to appear on all matched elements.
// WAIT_CLASS_ALL 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.
@ -19,7 +19,7 @@ func WaitClassAll(ctx context.Context, args ...core.Value) (core.Value, error) {
return waitClassAllWhen(ctx, args, drivers.WaitEventPresence)
}
// WaitClassAll waits for a class to disappear on all matched elements.
// WAIT_NO_CLASS_ALL waits for a class to disappear 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.

View File

@ -9,16 +9,16 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// WaitElement waits for element to appear in the DOM.
// WAIT_ELEMENT waits for element to appear in the DOM.
// Stops the execution until it finds an element or operation times out.
// @param doc (HTMLDocument) - Driver HTMLDocument.
// @param n (HTMLDocument) - Driver HTMLDocument.
// @param selector (String) - Target element's selector.
// @param timeout (Int, optional) - Optional timeout. Default 5000 ms.
func WaitElement(ctx context.Context, args ...core.Value) (core.Value, error) {
return waitElementWhen(ctx, args, drivers.WaitEventPresence)
}
// WaitNoElements waits for element to disappear in the DOM.
// WAIT_NO_ELEMENT waits for element to disappear in the DOM.
// Stops the execution until it does not find an element or operation times out.
// @param doc (HTMLDocument) - Driver HTMLDocument.
// @param selector (String) - Target element's selector.

View File

@ -9,7 +9,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// WaitNavigation waits for a given page to navigate to a new url.
// WAIT_NAVIGATION waits for a given page to navigate to a new url.
// Stops the execution until the navigation ends or operation times out.
// @param page (HTMLPage) - Target page.
// @param timeout (Int, optional) - Optional timeout. Default 5000 ms.

View File

@ -9,10 +9,12 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// WAIT_STYLE
func WaitStyle(ctx context.Context, args ...core.Value) (core.Value, error) {
return waitStyleWhen(ctx, args, drivers.WaitEventPresence)
}
// WAIT_NO_STYLE
func WaitNoStyle(ctx context.Context, args ...core.Value) (core.Value, error) {
return waitStyleWhen(ctx, args, drivers.WaitEventAbsence)
}

View File

@ -9,10 +9,12 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values/types"
)
// WAIT_STYLE_ALL
func WaitStyleAll(ctx context.Context, args ...core.Value) (core.Value, error) {
return waitStyleAllWhen(ctx, args, drivers.WaitEventPresence)
}
// WAIT_NO_STYLE_ALL
func WaitNoStyleAll(ctx context.Context, args ...core.Value) (core.Value, error) {
return waitStyleAllWhen(ctx, args, drivers.WaitEventAbsence)
}

View File

@ -8,7 +8,7 @@ import (
"github.com/MontFerret/ferret/pkg/runtime/values"
)
// XPath evaluates the XPath expression.
// XPATH evaluates the XPath expression.
// @param source (HTMLPage | HTMLDocument | HTMLElement) - Target HTML object.
// @param expression (String) - XPath expression.
// @returns (Value) - Returns result of a given XPath expression.