mirror of
https://github.com/MontFerret/ferret.git
synced 2025-03-17 21:18:37 +02:00
Feature/doc markup (#543)
* Added release notes * #509 fixedOCOD typo * Updated values * Updated comments * Changed stdlib docs format * Changed format of array in docs * Use 'any' instead of 'value' in docs * New format for optional params * Updated docs for testing package * Added namespace information
This commit is contained in:
parent
6c5aca52ab
commit
24d8eedd4c
15
CHANGELOG.md
15
CHANGELOG.md
@ -1,8 +1,21 @@
|
||||
## Changelog
|
||||
|
||||
### 0.12.0
|
||||
#### Added
|
||||
- iframe navigation handling [#535](https://github.com/MontFerret/ferret/pull/535)
|
||||
- Assertion library [#526](https://github.com/MontFerret/ferret/pull/526)
|
||||
|
||||
#### Changed
|
||||
- Removed property caching and tracking [#531](https://github.com/MontFerret/ferret/pull/531)
|
||||
- Updated dependencies [#528](https://github.com/MontFerret/ferret/pull/528), [#525](https://github.com/MontFerret/ferret/pull/525)
|
||||
|
||||
#### Fixed
|
||||
- ``WAIT`` does not respect cancellation signal [#524](https://github.com/MontFerret/ferret/pull/524)
|
||||
- Missed ``DATE_COMPARE`` [#537](https://github.com/MontFerret/ferret/pull/537)
|
||||
- Spelling [#534](https://github.com/MontFerret/ferret/pull/534)
|
||||
|
||||
### 0.11.1
|
||||
#### Fixed
|
||||
|
||||
- Fixed use of unquoted scroll options [#521](https://github.com/MontFerret/ferret/pull/521)
|
||||
- Upgraded ANTLR version [#517](https://github.com/MontFerret/ferret/pull/517)
|
||||
|
||||
|
@ -8,11 +8,11 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Append appends a new item to an array and returns a new array with a given element.
|
||||
// APPEND appends a new item to an array and returns a new array with a given element.
|
||||
// If ``uniqueOnly`` is set to true, then will add the item only if it's unique.
|
||||
// @param arr (Array) - Target array.
|
||||
// @param item (Read) - Target value to add.
|
||||
// @returns arr (Array) - New array.
|
||||
// @param {Any[]} arr - Target array.
|
||||
// @param {Any} item - Target value to add.
|
||||
// @return {Any[]} - New array.
|
||||
func Append(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 3)
|
||||
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// First returns a first element from a given array.
|
||||
// @param arr (Array) - Target array.
|
||||
// @returns element (Read) - First element in a given array.
|
||||
// FIRST returns a first element from a given array.
|
||||
// @param {Any[]} arr - Target array.
|
||||
// @return {Any} - First element in a given array.
|
||||
func First(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
|
||||
|
@ -8,14 +8,14 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Flatten turn an array of arrays into a flat array.
|
||||
// FLATTEN turns an array of arrays into a flat array.
|
||||
// All array elements in array will be expanded in the result array.
|
||||
// Non-array elements are added as they are.
|
||||
// The function will recurse into sub-arrays up to the specified depth.
|
||||
// Duplicates will not be removed.
|
||||
// @param arr (Array) - Target array.
|
||||
// @param depth (Int, optional) - Depth level.
|
||||
// @returns (Array) - Flat array.
|
||||
// @param {Any[]} arr - Target array.
|
||||
// @param {Int} [depth] - Depth level.
|
||||
// @return {Any[]} - Flat array.
|
||||
func Flatten(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 2)
|
||||
|
||||
|
@ -8,11 +8,11 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Intersection return the intersection of all arrays specified.
|
||||
// INTERSECTION return the intersection of all arrays specified.
|
||||
// The result is an array of values that occur in all arguments.
|
||||
// @param arrays (Array, repeated) - An arbitrary number of arrays as multiple arguments (at least 2).
|
||||
// @returns (Array) - A single array with only the elements, which exist in all provided arrays.
|
||||
// The element order is random. Duplicates are removed.
|
||||
// @param {Any[], repeated} arrays - An arbitrary number of arrays as multiple arguments (at least 2).
|
||||
// @return {Any[]} - A single array with only the elements, which exist in all provided arrays.
|
||||
func Intersection(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
return sections(args, len(args))
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Last returns the last element of an array.
|
||||
// @param array (Array) - The target array.
|
||||
// @returns (Read) - Last element of an array.
|
||||
// LAST returns the last element of an array.
|
||||
// @param {Any[]} array - The target array.
|
||||
// @return {Any} - Last element of an array.
|
||||
func Last(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
|
||||
|
@ -8,10 +8,10 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Minus return the difference of all arrays specified.
|
||||
// @param arrays (Array, repeated) - An arbitrary number of arrays as multiple arguments (at least 2).
|
||||
// @returns array (Array) - An array of values that occur in the first array, but not in any of the subsequent arrays.
|
||||
// MINUS return the difference of all arrays specified.
|
||||
// The order of the result array is undefined and should not be relied on. Duplicates will be removed.
|
||||
// @param {Any[], repeated} arrays - An arbitrary number of arrays as multiple arguments (at least 2).
|
||||
// @return {Any[]} - An array of values that occur in the first array, but not in any of the subsequent arrays.
|
||||
func Minus(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, core.MaxArgs)
|
||||
|
||||
|
@ -8,12 +8,12 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Nth returns the element of an array at a given position.
|
||||
// NTH returns the element of an array at a given position.
|
||||
// It is the same as anyArray[position] for positive positions, but does not support negative positions.
|
||||
// @param array (Array) - An array with elements of arbitrary type.
|
||||
// @param index (Int) - Position of desired element in array, positions start at 0.
|
||||
// @returns (Read) - The array element at the given position.
|
||||
// If position is negative or beyond the upper bound of the array, then NONE will be returned.
|
||||
// @param {Any[]} array - An array with elements of arbitrary type.
|
||||
// @param {Int} index - Position of desired element in array, positions start at 0.
|
||||
// @return {Any} - The array element at the given position.
|
||||
func Nth(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 2)
|
||||
|
||||
|
@ -6,10 +6,10 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/core"
|
||||
)
|
||||
|
||||
// Outersection return the values that occur only once across all arrays specified.
|
||||
// @param arrays (Array, repeated) - An arbitrary number of arrays as multiple arguments (at least 2).
|
||||
// @returns (Array) - A single array with only the elements that exist only once across all provided arrays.
|
||||
// OUTERSECTION return the values that occur only once across all arrays specified.
|
||||
// The element order is random.
|
||||
// @param {Any[], repeated} arrays - An arbitrary number of arrays as multiple arguments (at least 2).
|
||||
// @return {Any[]} - A single array with only the elements that exist only once across all provided arrays.
|
||||
func Outersection(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
return sections(args, 1)
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Pop returns a new array without last element.
|
||||
// @param array (Array) - Target array.
|
||||
// @returns (Array) - Copy of an array without last element.
|
||||
// POP returns a new array without last element.
|
||||
// @param {Any[]} array - Target array.
|
||||
// @return {Any[]} - Copy of an array without last element.
|
||||
func Pop(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
|
||||
|
@ -8,10 +8,11 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Position returns a value indicating whether an element is contained in array. Optionally returns its position.
|
||||
// @param array (Array) - The source array.
|
||||
// @param value (Read) - The target value.
|
||||
// @param returnIndex (Boolean, optional) - Read which indicates whether to return item's position.
|
||||
// POSITION returns a value indicating whether an element is contained in array. Optionally returns its position.
|
||||
// @param {Any[]} array - The source array.
|
||||
// @param {Any} value - The target value.
|
||||
// @param {Boolean} [position=False] - Boolean value which indicates whether to return item's position.
|
||||
// @return {Boolean | Int} - A value indicating whether an element is contained in array.
|
||||
func Position(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 3)
|
||||
|
||||
|
@ -8,11 +8,11 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Push create a new array with appended value.
|
||||
// @param array (Array) - Source array.
|
||||
// @param value (Read) - Target value.
|
||||
// @param unique (Boolean, optional) - Read indicating whether to do uniqueness check.
|
||||
// @returns (Array) - A new array with appended value.
|
||||
// PUSH create a new array with appended value.
|
||||
// @param {Any[]} array - Source array.
|
||||
// @param {Any} value - Target value.
|
||||
// @param {Boolean} [unique=False] - Read indicating whether to do uniqueness check.
|
||||
// @return {Any[]} - A new array with appended value.
|
||||
func Push(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 3)
|
||||
|
||||
|
@ -8,10 +8,10 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// RemoveNth returns a new array without an element by a given position.
|
||||
// @param array (Array) - Source array.
|
||||
// @param position (Int) - Target element position.
|
||||
// @return (Array) - A new array without an element by a given position.
|
||||
// REMOVE_NTH returns a new array without an element by a given position.
|
||||
// @param {Any[]} array - Source array.
|
||||
// @param {Int} position - Target element position.
|
||||
// @return {Any[]} - A new array without an element by a given position.
|
||||
func RemoveNth(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 2)
|
||||
|
||||
|
@ -8,12 +8,12 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// RemoveValue returns a new array with removed all occurrences of value in a given array.
|
||||
// REMOVE_VALUE returns a new array with removed all occurrences of value in a given array.
|
||||
// Optionally with a limit to the number of removals.
|
||||
// @param array (Array) - Source array.
|
||||
// @param value (Read) - Target value.
|
||||
// @param limit (Int, optional) - A limit to the number of removals.
|
||||
// @returns (Array) - A new array with removed all occurrences of value in a given array.
|
||||
// @param {Any[]} array - Source array.
|
||||
// @param {Any} value - Target value.
|
||||
// @param {Int} [limit] - A limit to the number of removals.
|
||||
// @return {Any[]} - A new array with removed all occurrences of value in a given array.
|
||||
func RemoveValue(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 3)
|
||||
|
||||
|
@ -8,10 +8,10 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// RemoveValues returns a new array with removed all occurrences of values in a given array.
|
||||
// @param array (Array) - Source array.
|
||||
// @param values (Array) - Target values.
|
||||
// @returns (Array) - A new array with removed all occurrences of values in a given array.
|
||||
// REMOVE_VALUES returns a new array with removed all occurrences of values in a given array.
|
||||
// @param {Any[]} array - Source array.
|
||||
// @param {Any[]} values - Target values.
|
||||
// @return {Any[]} - A new array with removed all occurrences of values in a given array.
|
||||
func RemoveValues(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 2)
|
||||
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Shift returns a new array without the first element.
|
||||
// @param array (Array) - Target array.
|
||||
// @returns (Array) - Copy of an array without the first element.
|
||||
// SHIFT returns a new array without the first element.
|
||||
// @param {Any[]} array - Target array.
|
||||
// @return {Any[]} - Copy of an array without the first element.
|
||||
func Shift(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
|
||||
|
@ -8,11 +8,11 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Slice returns a new sliced array.
|
||||
// @param array (Array) - Source array.
|
||||
// @param start (Int) - Start position of extraction.
|
||||
// @param length (Int, optional) - Read indicating how many elements to extract.
|
||||
// @returns (Array) - Sliced array.
|
||||
// SLICE returns a new sliced array.
|
||||
// @param {Any[]} array - Source array.
|
||||
// @param {Int} start - Start position of extraction.
|
||||
// @param {Int} [length] - Read indicating how many elements to extract.
|
||||
// @return {Any[]} - Sliced array.
|
||||
func Slice(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 3)
|
||||
|
||||
|
@ -8,10 +8,10 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Sorted sorts all elements in anyArray.
|
||||
// SORTED sorts all elements in anyArray.
|
||||
// The function will use the default comparison order for FQL value types.
|
||||
// @param array (Array) - Target array.
|
||||
// @returns (Array) - Sorted array.
|
||||
// @param {Any[]} array - Target array.
|
||||
// @return {Any[]} - Sorted array.
|
||||
func Sorted(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
|
||||
|
@ -8,11 +8,11 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// SortedUnique sorts all elements in anyArray.
|
||||
// SORTED_UNIQUE sorts all elements in anyArray.
|
||||
// The function will use the default comparison order for FQL value types.
|
||||
// Additionally, the values in the result array will be made unique
|
||||
// @param array (Array) - Target array.
|
||||
// @returns (Array) - Sorted array.
|
||||
// @param {Any[]} array - Target array.
|
||||
// @return {Any[]} - Sorted array.
|
||||
func SortedUnique(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Union returns the union of all passed arrays.
|
||||
// @param arrays (Array, repeated) - List of arrays to combine.
|
||||
// @returns (Array) - All array elements combined in a single array, in any order.
|
||||
// UNION returns the union of all passed arrays.
|
||||
// @param {Any[], repeated} arrays - List of arrays to combine.
|
||||
// @return {Any[]} - All array elements combined in a single array, in any order.
|
||||
func Union(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, core.MaxArgs)
|
||||
|
||||
|
@ -8,6 +8,9 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// UNION_DISTINCT returns the union of all passed arrays with unique values.
|
||||
// @param {Any[], repeated} arrays - List of arrays to combine.
|
||||
// @return {Any[]} - All unique array elements combined in a single array, in any order.
|
||||
func UnionDistinct(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, core.MaxArgs)
|
||||
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
)
|
||||
|
||||
// TestUnion returns the union of distinct values of all passed arrays.
|
||||
// @param arrays (Array, repeated) - List of arrays to combine.
|
||||
// @returns (Array) - All array elements combined in a single array, without duplicates, in any order.
|
||||
// @param arrays {Any[], repeated} - List of arrays to combine.
|
||||
// @return {Any[]} - All array elements combined in a single array, without duplicates, in any order.
|
||||
func TestUnion(t *testing.T) {
|
||||
Convey("Should union all arrays", t, func() {
|
||||
arr1 := values.NewArrayWith(
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Unique returns all unique elements from a given array.
|
||||
// @param array (Array) - Target array.
|
||||
// @returns (Array) - New array without duplicates.
|
||||
// UNIQUE returns all unique elements from a given array.
|
||||
// @param {Any[]} array - Target array.
|
||||
// @return {Any[]} - New array without duplicates.
|
||||
func Unique(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
|
||||
|
@ -8,12 +8,11 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Unshift prepends value to a given array.
|
||||
// @param array (Array) - Target array.
|
||||
// @param value (Read) - Target value to prepend.
|
||||
// @param unique (Boolean, optional) - Optional value indicating whether a value must be unique to be prepended.
|
||||
// Default is false.
|
||||
// @returns (Array) - New array with prepended value.
|
||||
// UNSHIFT prepends value to a given array.
|
||||
// @param {Any[]} array - Target array.
|
||||
// @param {Any} value - Target value to prepend.
|
||||
// @param {Boolean} [unique=False] - Optional value indicating whether a value must be unique to be prepended. Default is false.
|
||||
// @return {Any[]} - New array with prepended value.
|
||||
func Unshift(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 3)
|
||||
|
||||
|
@ -8,10 +8,10 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Includes checks whether a container includes a given value.
|
||||
// @param text (String|Array|Object|Iterable) - The value container.
|
||||
// @param text (Mixed) - The target value to assert.
|
||||
// @returns (Boolean) - Returns a boolean value that indicates whether a container contains a given value.
|
||||
// INCLUDES checks whether a container includes a given value.
|
||||
// @param {String | Any[] | Object | Iterable} haystack - The value container.
|
||||
// @param {Any} needle - The target value to assert.
|
||||
// @return {Boolean} - A boolean value that indicates whether a container contains a given value.
|
||||
func Includes(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 2)
|
||||
|
||||
|
@ -9,6 +9,9 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// LENGTH returns the length of a measurable value.
|
||||
// @param {Measurable} value - The value to measure.
|
||||
// @return {Int} - The length of the value.
|
||||
func Length(_ context.Context, inputs ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(inputs, 1, 1)
|
||||
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values"
|
||||
)
|
||||
|
||||
// Reverse returns the reverse of a given string or array value.
|
||||
// @param text (String|Array) - The string or array to reverse.
|
||||
// @returns (String|Array) - Returns a reversed version of a given value.
|
||||
// REVERSE returns the reverse of a given string or array value.
|
||||
// @param {String | Any[]} value - The string or array to reverse.
|
||||
// @return {String | Any[]} - A reversed version of a given value.
|
||||
func Reverse(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
|
||||
|
@ -14,11 +14,7 @@ var (
|
||||
emptyString values.String
|
||||
)
|
||||
|
||||
// DATE_ADD add amount given in unit to date.
|
||||
// @params date (DateTime) - source date.
|
||||
// @params amount (Int) - amount of units
|
||||
// @params unit (String) - unit.
|
||||
// @return (DateTime) - calculated date.
|
||||
// DATE_ADD adds amount given in unit to date.
|
||||
// The following units are available:
|
||||
// * y, year, year
|
||||
// * m, month, months
|
||||
@ -28,6 +24,10 @@ var (
|
||||
// * i, minute, minutes
|
||||
// * s, second, seconds
|
||||
// * f, millisecond, milliseconds
|
||||
// @param {DateTime} date - Source date.
|
||||
// @param {Int} amount - Amount of units
|
||||
// @param {String} unit - Unit.
|
||||
// @return {DateTime} - Calculated date.
|
||||
func DateAdd(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
date, amount, unit, err := getArgs(args)
|
||||
if err != nil {
|
||||
@ -45,10 +45,6 @@ func DateAdd(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
}
|
||||
|
||||
// DATE_SUBTRACT subtract amount given in unit to date.
|
||||
// @params date (DateTime) - source date.
|
||||
// @params amount (Int) - amount of units
|
||||
// @params unit (String) - unit.
|
||||
// @return (DateTime) - calculated date.
|
||||
// The following units are available:
|
||||
// * y, year, year
|
||||
// * m, month, months
|
||||
@ -58,6 +54,10 @@ func DateAdd(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
// * i, minute, minutes
|
||||
// * s, second, seconds
|
||||
// * f, millisecond, milliseconds
|
||||
// @param {DateTime} date - source date.
|
||||
// @param {Int} amount - amount of units
|
||||
// @param {String} unit - unit.
|
||||
// @return {DateTime} - calculated date.
|
||||
func DateSubtract(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
date, amount, unit, err := getArgs(args)
|
||||
if err != nil {
|
||||
|
@ -9,12 +9,12 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// DATE_COMPARE check if two partial dates match.
|
||||
// @params date1, date2 (DateTime) - comparable dates.
|
||||
// @params unitRangeStart (String) - unit to start from.
|
||||
// @params unitRangeEnd (String, Optional) - unit to end with.
|
||||
// Error will be returned if unitRangeStart unit less that unitRangeEnd.
|
||||
// @return (Boolean) - true if the dates match, else false.
|
||||
// DATE_COMPARE checks if two partial dates match.
|
||||
// @param {DateTime} date1 - First date.
|
||||
// @param {DateTime} date2 - Second date.
|
||||
// @param {String} unitRangeStart - Unit to start from.
|
||||
// @param {String} [unitRangeEnd="millisecond"] - Unit to end with. Error will be returned if unitRangeStart unit less that unitRangeEnd.
|
||||
// @return {Boolean} - True if the dates match, else false.
|
||||
func DateCompare(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 3, 4)
|
||||
if err != nil {
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// DATE convert RFC3339 date time string to DateTime object.
|
||||
// @params timeString (String) - string in RFC3339 format.
|
||||
// @return (DateTime) - new DateTime object derived from timeString.
|
||||
// DATE converts RFC3339 date time string to DateTime object.
|
||||
// @param {String} time - String in RFC3339 format.
|
||||
// @return {DateTime} - New DateTime object derived from timeString.
|
||||
func Date(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
if err != nil {
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// DATE_DAY returns the day of date as a number.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a day number.
|
||||
// @param {DateTime} date - Source DateTime.
|
||||
// @return {Int} - A day number.
|
||||
func DateDay(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
if err != nil {
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// DATE_DAYOFWEEK returns number of the weekday from the date. Sunday is the 0th day of week.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - return number of the weekday.
|
||||
// @param {DateTime} date - Source DateTime.
|
||||
// @return {Int} - Number of the weekday.
|
||||
func DateDayOfWeek(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
if err != nil {
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
|
||||
// DATE_DAYOFYEAR returns the day of year number of date.
|
||||
// The return value range from 1 to 365 (366 in a leap year).
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a day of year number.
|
||||
// @param {DateTime} date - Source DateTime.
|
||||
// @return {Int} - A day of year number.
|
||||
func DateDayOfYear(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
if err != nil {
|
||||
|
@ -25,8 +25,8 @@ var daysCount = map[time.Month]int{
|
||||
}
|
||||
|
||||
// DATE_DAYS_IN_MONTH returns the number of days in the month of date.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - number of the days.
|
||||
// @param {DateTime} date - Source DateTime.
|
||||
// @return {Int} - Number of the days.
|
||||
func DateDaysInMonth(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
if err != nil {
|
||||
|
@ -9,11 +9,11 @@ import (
|
||||
)
|
||||
|
||||
// DATE_DIFF returns the difference between two dates in given time unit.
|
||||
// @params date1 (DateTime) - first DateTime.
|
||||
// @params date2 (DateTime) - second DateTime.
|
||||
// @params unit (String) - time unit to return the difference in.
|
||||
// @params asFloat (Boolean, optional) - if true amount of unit will be as float.
|
||||
// @return (Int, Float) - difference between date1 and date2.
|
||||
// @param {DateTime} date1 - First date.
|
||||
// @param {DateTime} date2 - Second date.
|
||||
// @param {String} unit - Time unit to return the difference in.
|
||||
// @param {Boolean} [asFloat=False] - If true amount of unit will be as float.
|
||||
// @return {Int | Float} - Difference between date1 and date2.
|
||||
func DateDiff(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 3, 4)
|
||||
if err != nil {
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// DATE_FORMAT format date according to the given format string.
|
||||
// @params date (DateTime) - source DateTime object.
|
||||
// @return (String) - formatted date.
|
||||
// @param {DateTime} date - Source DateTime object.
|
||||
// @return {String} - Formatted date.
|
||||
func DateFormat(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 2)
|
||||
if err != nil {
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// DATE_HOUR returns the hour of date as a number.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a hour number.
|
||||
// @param {DateTime} date - Source DateTime.
|
||||
// @return {Int} - An hour number.
|
||||
func DateHour(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
if err != nil {
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// DATE_LEAPYEAR returns true if date is in a leap year else false.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Boolean) - date is in a leap year.
|
||||
// @param {DateTime} date - Source DateTime.
|
||||
// @return {Boolean} - Date is in a leap year.
|
||||
func DateLeapYear(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
if err != nil {
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// DATE_MILLISECOND returns the millisecond of date as a number.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a millisecond number.
|
||||
// @param {DateTime} date - Source DateTime.
|
||||
// @return {Int} - A millisecond number.
|
||||
func DateMillisecond(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
if err != nil {
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// DATE_MINUTE returns the minute of date as a number.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a minute number.
|
||||
// @param {DateTime} date -Source DateTime.
|
||||
// @return {Int} - A minute number.
|
||||
func DateMinute(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
if err != nil {
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// DATE_MONTH returns the month of date as a number.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a month number.
|
||||
// @param {DateTime} date - Source DateTime.
|
||||
// @return {Int} - A month number.
|
||||
func DateMonth(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
if err != nil {
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
// NOW returns new DateTime object with Time equal to time.Now().
|
||||
// @returns (DateTime) - New DateTime object.
|
||||
// @return {DateTime} - New DateTime object.
|
||||
func Now(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 0, 0)
|
||||
if err != nil {
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
)
|
||||
|
||||
// DATE_QUARTER returns which quarter date belongs to.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a quarter number.
|
||||
// @param {DateTime} date - Source DateTime.
|
||||
// @return {Int} - A quarter number.
|
||||
func DateQuarter(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
if err != nil {
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// DATE_SECOND returns the second of date as a number.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a second number.
|
||||
// @param {DateTime} date - Source DateTime.
|
||||
// @return {Int} - A second number.
|
||||
func DateSecond(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
if err != nil {
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// DATE_YEAR returns the year extracted from the given date.
|
||||
// @params date (DateTime) - source DateTime.
|
||||
// @return (Int) - a year number.
|
||||
// @param {DateTime} date - Source DateTime.
|
||||
// @return {Int} - A year number.
|
||||
func DateYear(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
if err != nil {
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target node.
|
||||
// @param {String, repeated} attrNames - Attribute name(s).
|
||||
// @return {Object} - Key-value pairs of attribute values.
|
||||
func AttributeGet(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, core.MaxArgs)
|
||||
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
)
|
||||
|
||||
// ATTR_REMOVE removes single or more attribute(s) of a given element.
|
||||
// @param el (HTMLElement) - Target element.
|
||||
// @param names (...String) - Attribute name(s).
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target node.
|
||||
// @param {String, repeated} attrNames - Attribute name(s).
|
||||
func AttributeRemove(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, core.MaxArgs)
|
||||
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target node.
|
||||
// @param {String | Object} nameOrObj - Attribute name or an object representing a key-value pair of attributes.
|
||||
// @param {String} value - If a second parameter is a string value, this parameter represent an attribute value.
|
||||
func AttributeSet(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, core.MaxArgs)
|
||||
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// BLUR Calls blur on the element.
|
||||
// @param target (HTMLPage | HTMLDocument | HTMLElement) - Target node.
|
||||
// @param selector (String, optional) - Optional CSS selector.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target node.
|
||||
// @param {String} [selector] - CSS selector.
|
||||
func Blur(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 2)
|
||||
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// INPUT_CLEAR clears a value from an underlying input element.
|
||||
// @param source (HTMLPage | HTMLDocument | HTMLElement) - Event target.
|
||||
// @param selector (String, options) - Selector.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} [selector] - CSS selector.
|
||||
func InputClear(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 2)
|
||||
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String | Int} [cssSelectorOrClicks] - CSS selector or count of clicks.
|
||||
// @param {Int} [clicks=1] - Count of clicks.
|
||||
func Click(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 3)
|
||||
|
||||
|
@ -10,10 +10,10 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @returns (Boolean) - Returns true if matched at least one element.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - CSS selector.
|
||||
// @param {Int} [clicks=1] - Optional count of clicks.
|
||||
// @return {Boolean} - True if matched at least one element.
|
||||
func ClickAll(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 3)
|
||||
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage} page - Target page.
|
||||
// @param {HTTPCookie, repeated | String, repeated} cookiesOrNames - Cookie or cookie name to delete.
|
||||
func CookieDel(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, core.MaxArgs)
|
||||
|
||||
|
@ -10,8 +10,9 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage} page - Target page.
|
||||
// @param {String} name - Cookie or cookie name to delete.
|
||||
// @return {HTTPCookie} - Cookie if found, otherwise None.
|
||||
func CookieGet(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 2)
|
||||
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// COOKIE_SET sets cookies to a given page
|
||||
// @param page (HTMLPage) - Target page.
|
||||
// @param cookie... (HTTPCookie) - Target cookies.
|
||||
// @param {HTMLPage} page - Target page.
|
||||
// @param {HTTPCookie, repeated} cookies - Target cookies.
|
||||
func CookieSet(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, core.MaxArgs)
|
||||
|
||||
|
@ -20,16 +20,20 @@ type PageLoadParams struct {
|
||||
|
||||
// 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.
|
||||
// timeout (Int) - Optional, timeout.
|
||||
// userAgent (String) - Optional, user agent.
|
||||
// keepCookies (Boolean) - Optional, boolean value indicating whether to use cookies from previous sessions.
|
||||
// i.e. not to open a page in the Incognito mode.
|
||||
// cookies (HTTPCookies) - Optional, set of HTTP cookies.
|
||||
// headers (HTTPHeaders) - Optional, HTTP headers.
|
||||
// viewport (Viewport) - Optional, viewport params.
|
||||
// @returns (HTMLPage) - Returns loaded HTML page.
|
||||
// @param {Object} [params] - An object containing the following properties :
|
||||
// @param {String} [params.driver] - Driver name to use.
|
||||
// @param {Int} [params.timeout=60000] - Page load timeout.
|
||||
// @param {String} [params.userAgent] - Custom user agent.
|
||||
// @param {Boolean} [params.keepCookies=False] - Boolean value indicating whether to use cookies from previous sessions i.e. not to open a page in the Incognito mode.
|
||||
// @param {HTTPCookies} [params.cookies] - Set of HTTP cookies to use during page loading.
|
||||
// @param {HTTPHeaders} [params.headers] - Set of HTTP headers to use during page loading.
|
||||
// @param {Object} [params.viewport] - Viewport params.
|
||||
// @param {Int} [params.viewport.height] - Viewport height.
|
||||
// @param {Int} [params.viewport.width] - Viewport width.
|
||||
// @param {Float} [params.viewport.scaleFactor] - Viewport scale factor.
|
||||
// @param {Boolean} [params.viewport.mobile] - Value that indicates whether to emulate mobile device.
|
||||
// @param {Boolean} [params.viewport.landscape] - Value that indicates whether to render a page in landscape position.
|
||||
// @return {HTMLPage} - Loaded HTML page.
|
||||
func Open(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 2)
|
||||
|
||||
|
@ -11,8 +11,8 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {String} url - URL to download.
|
||||
// @return {Binary} - A base64 encoded string in binary format.
|
||||
func Download(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
|
||||
|
@ -11,9 +11,9 @@ import (
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - CSS selector.
|
||||
// @return {HTMLElement} - A matched HTML element
|
||||
func Element(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
el, selector, err := queryArgs(args)
|
||||
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - CSS selector.
|
||||
// @return {Boolean} - A boolean value indicating whether there is an element matched by selector.
|
||||
func ElementExists(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
el, selector, err := queryArgs(args)
|
||||
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
|
||||
// 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.
|
||||
// @returns (Array) - Returns an array of found HTML element.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - CSS selector.
|
||||
// @return {HTMLElement[]} - An array of matched HTML elements.
|
||||
func Elements(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
el, selector, err := queryArgs(args)
|
||||
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
|
||||
// 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.
|
||||
// @returns (Int) - A number of found HTML elements by a given CSS selector.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - CSS selector.
|
||||
// @return {Int} - A number of matched HTML elements by a given CSS selector.
|
||||
func ElementsCount(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
el, selector, err := queryArgs(args)
|
||||
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
|
||||
// FRAMES finds HTML frames by a given property selector.
|
||||
// Returns an empty array if frames not found.
|
||||
// @param page (HTMLPage) - HTML page.
|
||||
// @param prop (String) - Property selector.
|
||||
// @param value (Any) - Property value.
|
||||
// @returns (Array) - Returns an array of found HTML frames.
|
||||
// @param {HTMLPage} page - HTML page.
|
||||
// @param {String} property - Property selector.
|
||||
// @param {Any} value - Property value.
|
||||
// @return {HTMLDocument[]} - Returns an array of found HTML frames.
|
||||
func Frames(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 3, 3)
|
||||
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
// FOCUS Sets focus on the element.
|
||||
// @param target (HTMLPage | HTMLDocument | HTMLElement) - Target node.
|
||||
// @param selector (String, optional) - Optional CSS selector.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} [selector] - CSS selector.
|
||||
func Focus(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 2)
|
||||
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} [selector] - String of CSS selector.
|
||||
// @return {String} - Inner HTML string if a matched element, otherwise empty string.
|
||||
func GetInnerHTML(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 2)
|
||||
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - String of CSS selector.
|
||||
// @return {String[]} - An array of inner HTML strings if all matched elements, otherwise empty array.
|
||||
func GetInnerHTMLAll(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 2)
|
||||
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} [selector] - String of CSS selector.
|
||||
// @return {String} - Inner text if a matched element, otherwise empty string.
|
||||
func GetInnerText(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 2)
|
||||
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - String of CSS selector.
|
||||
// @return {String[]} - An array of inner text if all matched elements, otherwise empty array.
|
||||
func GetInnerTextAll(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 2)
|
||||
|
||||
|
@ -11,8 +11,8 @@ import (
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} [selector] - If document is passed, this param must represent an element selector.
|
||||
func Hover(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 2)
|
||||
|
||||
|
@ -9,11 +9,11 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param delay (Int, optional) - Target value.
|
||||
// @returns (Boolean) - Returns true if an element was found.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} valueOrSelector - CSS selector or a value.
|
||||
// @param {String} value - Target value.
|
||||
// @param {Int} [delay] - Target value.
|
||||
// @return {Boolean} - Returns true if an element was found.
|
||||
func Input(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 4)
|
||||
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
// MOUSE moves mouse by given coordinates.
|
||||
// @param doc (HTMLDocument) - HTML document.
|
||||
// @param x (Int|Float) - X coordinate.
|
||||
// @param y (Int|Float) - Y coordinate.
|
||||
// @param {HTMLDocument} document - HTML document.
|
||||
// @param {Int|Float} x - X coordinate.
|
||||
// @param {Int|Float} y - Y coordinate.
|
||||
func MouseMoveXY(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 3, 3)
|
||||
|
||||
|
@ -12,9 +12,9 @@ import (
|
||||
// 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.
|
||||
// @param url (String) - Target url to navigate.
|
||||
// @param timeout (Int, optional) - Optional timeout. Default is 5000.
|
||||
// @param {HTMLPage} page - Target page.
|
||||
// @param {String} url - Target url to navigate.
|
||||
// @param {Int} [timeout=5000] - Navigation timeout.
|
||||
func Navigate(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 3)
|
||||
|
||||
|
@ -12,10 +12,10 @@ import (
|
||||
// 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.
|
||||
// @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.
|
||||
// @param {HTMLPage} page - Target page.
|
||||
// @param {Int} [entry=1] - An integer value indicating how many pages to skip.
|
||||
// @param {Int} [timeout=5000] - Navigation timeout.
|
||||
// @return {Boolean} - True if history exists and the operation succeeded, otherwise false.
|
||||
func NavigateBack(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 3)
|
||||
|
||||
|
@ -12,10 +12,10 @@ import (
|
||||
// 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.
|
||||
// @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.
|
||||
// @param {HTMLPage} page - Target page.
|
||||
// @param {Int} [entry=1] - An integer value indicating how many pages to skip.
|
||||
// @param {Int} [timeout=5000] - Navigation timeout.
|
||||
// @return {Boolean} - True if history exists and the operation succeeded, otherwise false.
|
||||
func NavigateForward(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 3)
|
||||
|
||||
|
@ -12,8 +12,8 @@ import (
|
||||
// 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.
|
||||
// @param selector (String) - CSS selector for a pagination on the page.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - CSS selector for a pagination on the page.
|
||||
func Pagination(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 2)
|
||||
|
||||
|
@ -16,14 +16,19 @@ type ParseParams struct {
|
||||
}
|
||||
|
||||
// PARSE loads an HTML page from a given string or byte array
|
||||
// @param params (Object) - Optional, an object containing the following properties :
|
||||
// driver (String) - Optional, driver name.
|
||||
// keepCookies (Boolean) - Optional, boolean value indicating whether to use cookies from previous sessions.
|
||||
// i.e. not to open a page in the Incognito mode.
|
||||
// cookies (HTTPCookies) - Optional, set of HTTP cookies.
|
||||
// headers (HTTPHeaders) - Optional, HTTP headers.
|
||||
// viewport (Viewport) - Optional, viewport params.
|
||||
// @returns (HTMLPage) - Returns parsed and loaded HTML page.
|
||||
// @param {String} html - HTML string to parse.
|
||||
// @param {Object} [params] - An object containing the following properties:
|
||||
// @param {String} [params.driver] - Name of a driver to parse with.
|
||||
// @param {Boolean} [params.keepCookies=False] - Boolean value indicating whether to use cookies from previous sessions i.e. not to open a page in the Incognito mode.
|
||||
// @param {HTTPCookies} [params.cookies] - Set of HTTP cookies to use during page loading.
|
||||
// @param {HTTPHeaders} [params.headers] - Set of HTTP headers to use during page loading.
|
||||
// @param {Object} [params.viewport] - Viewport params.
|
||||
// @param {Int} [params.viewport.height] - Viewport height.
|
||||
// @param {Int} [params.viewport.width] - Viewport width.
|
||||
// @param {Float} [params.viewport.scaleFactor] - Viewport scale factor.
|
||||
// @param {Boolean} [params.viewport.mobile] - Value that indicates whether to emulate mobile device.
|
||||
// @param {Boolean} [params.viewport.landscape] - Value that indicates whether to render a page in landscape position.
|
||||
// @return {HTMLPage} - Returns parsed and loaded HTML page.
|
||||
func Parse(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
if err := core.ValidateArgs(args, 1, 2); err != nil {
|
||||
return values.None, err
|
||||
|
@ -22,24 +22,24 @@ func ValidatePageRanges(pageRanges string) (bool, error) {
|
||||
}
|
||||
|
||||
// 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.
|
||||
// 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.
|
||||
// @param {HTMLPage | String}target - Target page or url.
|
||||
// @param {Object} [params] - An object containing the following properties:
|
||||
// @param {Bool} [params.landscape=False] - Paper orientation.
|
||||
// @param {Bool} [params.displayHeaderFooter=False] - Display header and footer.
|
||||
// @param {Bool} [params.printBackground=False] - Print background graphics.
|
||||
// @param {Float} [params.scale=1] - Scale of the webpage rendering.
|
||||
// @param {Float} [params.paperWidth=22] - Paper width in inches.
|
||||
// @param {Float} [params.paperHeight=28] - Paper height in inches.
|
||||
// @param {Float} [params.marginTo=1] - Top margin in inches.
|
||||
// @param {Float} [params.marginBottom=1] - Bottom margin in inches.
|
||||
// @param {Float} [params.marginLeft=1] - Left margin in inches.
|
||||
// @param {Float} [params.marginRight=1] - Right margin in inches.
|
||||
// @param {String} [params.pageRanges] - Paper ranges to print, e.g., '1-5, 8, 11-13'.
|
||||
// @param {Bool} [params.ignoreInvalidPageRanges=False] - to silently ignore invalid but successfully parsed page ranges, such as '3-2'.
|
||||
// @param {String} [params.headerTemplate] - 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.
|
||||
// @param {String} [params.footerTemplate] - HTML template for the print footer. Should use the same format as the `headerTemplate`.
|
||||
// @param {Bool} [params.preferCSSPageSize=False] - 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. *
|
||||
// @return {Binary} - PDF document in binary format.
|
||||
func PDF(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 2)
|
||||
|
||||
|
@ -11,15 +11,15 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// 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.
|
||||
// @param {HTMLPage|String} target - Target page or url.
|
||||
// @param {Object} [params] - An object containing the following properties :
|
||||
// @param {Float | Int} [params.x=0] - X position of the viewport.
|
||||
// @param {Float | Int} [params.y=0] - Y position of the viewport.
|
||||
// @param {Float | Int} [params.width] - Width of the viewport.
|
||||
// @param {Float | Int} [params.height] - Height of the viewport.
|
||||
// @param {String} [params.format="jpeg"] - Either "jpeg" or "png".
|
||||
// @param {Int} [params.quality=100] - Quality, in [0, 100], only for jpeg format.
|
||||
// @return {Binary} - Screenshot in binary format.
|
||||
func Screenshot(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 2)
|
||||
|
||||
|
@ -9,8 +9,13 @@ import (
|
||||
)
|
||||
|
||||
// SCROLL_BOTTOM scrolls the document's window to its bottom.
|
||||
// @param doc (HTMLDocument) - Target document.
|
||||
// @param options (ScrollOptions) - Scroll options. Optional.
|
||||
// @param {HTMLDocument} document - HTML document.
|
||||
// @param {Int | Float} x - X coordinate.
|
||||
// @param {Int | Float} y - Y coordinate.
|
||||
// @param {Object} [params] - Scroll params.
|
||||
// @param {String} [params.behavior="instant"] - Scroll behavior
|
||||
// @param {String} [params.block="center"] - Scroll vertical alignment.
|
||||
// @param {String} [params.inline="center"] - Scroll horizontal alignment.
|
||||
func ScrollBottom(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 2)
|
||||
|
||||
|
@ -12,9 +12,12 @@ import (
|
||||
)
|
||||
|
||||
// SCROLL_ELEMENT scrolls an element on.
|
||||
// @param docOrEl (HTMLDocument|HTMLElement) - Target document or element.
|
||||
// @param selector (String) - If document is passed, this param must represent an element selector.
|
||||
// @param options (ScrollOptions) - Scroll options. Optional.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - If document is passed, this param must represent an element selector.
|
||||
// @param {Object} [params] - Scroll params.
|
||||
// @param {String} [params.behavior="instant"] - Scroll behavior
|
||||
// @param {String} [params.block="center"] - Scroll vertical alignment.
|
||||
// @param {String} [params.inline="center"] - Scroll horizontal alignment.
|
||||
func ScrollInto(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 3)
|
||||
|
||||
|
@ -9,8 +9,13 @@ import (
|
||||
)
|
||||
|
||||
// SCROLL_TOP scrolls the document's window to its top.
|
||||
// @param doc (HTMLDocument) - Target document.
|
||||
// @param options (ScrollOptions) - Scroll options. Optional.
|
||||
// @param {HTMLDocument} document - HTML document.
|
||||
// @param {Int | Float} x - X coordinate.
|
||||
// @param {Int | Float} y - Y coordinate.
|
||||
// @param {Object} [params] - Scroll params.
|
||||
// @param {String} [params.behavior="instant"] - Scroll behavior
|
||||
// @param {String} [params.block="center"] - Scroll vertical alignment.
|
||||
// @param {String} [params.inline="center"] - Scroll horizontal alignment.
|
||||
func ScrollTop(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 2)
|
||||
|
||||
|
@ -10,10 +10,13 @@ import (
|
||||
)
|
||||
|
||||
// SCROLL scrolls by given coordinates.
|
||||
// @param doc (HTMLDocument) - HTML document.
|
||||
// @param x (Int|Float) - X coordinate.
|
||||
// @param y (Int|Float) - Y coordinate.
|
||||
// @param options (ScrollOptions) - Scroll options. Optional.
|
||||
// @param {HTMLDocument} document - HTML document.
|
||||
// @param {Int | Float} x - X coordinate.
|
||||
// @param {Int | Float} y - Y coordinate.
|
||||
// @param {Object} [params] - Scroll params.
|
||||
// @param {String} [params.behavior="instant"] - Scroll behavior
|
||||
// @param {String} [params.block="center"] - Scroll vertical alignment.
|
||||
// @param {String} [params.inline="center"] - Scroll horizontal alignment.
|
||||
func ScrollXY(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 3, 4)
|
||||
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @returns (Array<String>) - Returns an array of selected values.
|
||||
// @param {HTMLElement} element - Target html element.
|
||||
// @param {String | String[]} valueOrSelector - Selector or a an array of strings as a value.
|
||||
// @param {String[]} value - Target value. Optional.
|
||||
// @return {String[]} - Array of selected values.
|
||||
func Select(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 4)
|
||||
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} htmlOrSelector - HTML or CSS selector.
|
||||
// @param {String} [html] - String of inner HTML.
|
||||
func SetInnerHTML(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 3)
|
||||
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} textOrCssSelector - String of CSS selector.
|
||||
// @param {String} [text] - String of inner text.
|
||||
func SetInnerText(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 3)
|
||||
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLElement} element - Target html element.
|
||||
// @param {String, repeated} names - Style name(s).
|
||||
// @return {Object} - Collection of key-value pairs of style values.
|
||||
func StyleGet(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, core.MaxArgs)
|
||||
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
)
|
||||
|
||||
// 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).
|
||||
// @param {HTMLElement} element - Target html element.
|
||||
// @param {String, repeated} names - Style name(s).
|
||||
func StyleRemove(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, core.MaxArgs)
|
||||
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLElement} element - Target html element.
|
||||
// @param {String | Object} nameOrObj - Style name or an object representing a key-value pair of attributes.
|
||||
// @param {String} value - If a second parameter is a string value, this parameter represent a style value.
|
||||
func StyleSet(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, core.MaxArgs)
|
||||
|
||||
|
@ -10,21 +10,21 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} attrNameOrSelector - String of an attr name or CSS selector.
|
||||
// @param {String | Any} attrValueOrAttrName - Attr value or name.
|
||||
// @param {Any | Int} [attrValueOrTimeout] - Attr value or a timeout.
|
||||
// @param {Int} [timeout=5000] - Wait 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} attrNameOrSelector - String of an attr name or CSS selector.
|
||||
// @param {String | Any} attrValueOrAttrName - Attr value or name.
|
||||
// @param {Any | Int} [attrValueOrTimeout] - Attr value or wait timeout.
|
||||
// @param {Int} [timeout=5000] - Wait timeout.
|
||||
func WaitNoAttribute(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return waitAttributeWhen(ctx, args, drivers.WaitEventAbsence)
|
||||
}
|
||||
|
@ -11,20 +11,20 @@ import (
|
||||
|
||||
// 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.
|
||||
// @param class (String) - String of target CSS class.
|
||||
// @param timeout (Int, optional) - Optional timeout.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - String of CSS selector.
|
||||
// @param {String} class - String of target CSS class.
|
||||
// @param {Int} [timeout=5000] - Wait timeout.
|
||||
func WaitAttributeAll(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return waitAttributeAllWhen(ctx, args, drivers.WaitEventPresence)
|
||||
}
|
||||
|
||||
// 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.
|
||||
// @param class (String) - String of target CSS class.
|
||||
// @param timeout (Int, optional) - Optional timeout.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - String of CSS selector.
|
||||
// @param {String} class - String of target CSS class.
|
||||
// @param {Int} [timeout=5000] - Wait timeout.
|
||||
func WaitNoAttributeAll(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return waitAttributeAllWhen(ctx, args, drivers.WaitEventAbsence)
|
||||
}
|
||||
|
@ -11,26 +11,20 @@ import (
|
||||
|
||||
// WAIT_CLASS waits for a class to appear on a given element.
|
||||
// Stops the execution until the navigation ends or operation times out.
|
||||
// @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.
|
||||
// Otherwise timeout.
|
||||
// @param timeout (Int, optional) - If document is passed, this param must represent timeout.
|
||||
// Otherwise not passed.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selectorOrClass - If document is passed, this param must represent an element selector. Otherwise target class.
|
||||
// @param {String | Int} [classOrTimeout] - If document is passed, this param must represent target class name. Otherwise timeout.
|
||||
// @param {Int} [timeout] - If document is passed, this param must represent timeout. Otherwise not passed.
|
||||
func WaitClass(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return waitClassWhen(ctx, args, drivers.WaitEventPresence)
|
||||
}
|
||||
|
||||
// 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 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.
|
||||
// Otherwise timeout.
|
||||
// @param timeout (Int, optional) - If document is passed, this param must represent timeout.
|
||||
// Otherwise not passed.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selectorOrClass - If document is passed, this param must represent an element selector. Otherwise target class.
|
||||
// @param {String | Int} [classOrTimeout] - If document is passed, this param must represent target class name. Otherwise timeout.
|
||||
// @param {Int} [timeout] - If document is passed, this param must represent timeout. Otherwise not passed.
|
||||
func WaitNoClass(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return waitClassWhen(ctx, args, drivers.WaitEventAbsence)
|
||||
}
|
||||
|
@ -11,20 +11,20 @@ import (
|
||||
|
||||
// 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.
|
||||
// @param class (String) - String of target CSS class.
|
||||
// @param timeout (Int, optional) - Optional timeout.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - String of CSS selector.
|
||||
// @param {String} class - String of target CSS class.
|
||||
// @param {Int} [timeout=5000] - Wait timeout.
|
||||
func WaitClassAll(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return waitClassAllWhen(ctx, args, drivers.WaitEventPresence)
|
||||
}
|
||||
|
||||
// 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.
|
||||
// @param class (String) - String of target CSS class.
|
||||
// @param timeout (Int, optional) - Optional timeout.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - String of CSS selector.
|
||||
// @param {String} class - String of target CSS class.
|
||||
// @param {Int} [timeout=5000] - Wait timeout.
|
||||
func WaitNoClassAll(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return waitClassAllWhen(ctx, args, drivers.WaitEventAbsence)
|
||||
}
|
||||
|
@ -11,18 +11,18 @@ import (
|
||||
|
||||
// WAIT_ELEMENT waits for element to appear in the DOM.
|
||||
// Stops the execution until it finds an element or operation times out.
|
||||
// @param n (HTMLDocument) - Driver HTMLDocument.
|
||||
// @param selector (String) - Target element's selector.
|
||||
// @param timeout (Int, optional) - Optional timeout. Default 5000 ms.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - Target element's selector.
|
||||
// @param {Int} [timeout=5000] - Wait timeout.
|
||||
func WaitElement(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return waitElementWhen(ctx, args, drivers.WaitEventPresence)
|
||||
}
|
||||
|
||||
// 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.
|
||||
// @param timeout (Int, optional) - Optional timeout. Default 5000 ms.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} selector - Target element's selector.
|
||||
// @param {Int} [timeout=5000] - Wait timeout.
|
||||
func WaitNoElement(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return waitElementWhen(ctx, args, drivers.WaitEventAbsence)
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ type WaitNavigationParams struct {
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage} page - Target page.
|
||||
// @param {Int} [timeout=5000] - Navigation timeout.
|
||||
func WaitNavigation(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 2)
|
||||
|
||||
|
@ -9,12 +9,22 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// WAIT_STYLE
|
||||
// WAIT_STYLE waits until a target style value appears
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} styleNameOrSelector - Style name or CSS selector.
|
||||
// @param {String | Any} valueOrStyleName - Style value or name.
|
||||
// @param {Any | Int} [valueOrTimeout] - Style value or wait timeout.
|
||||
// @param {Int} [timeout=5000] - Wait timeout.
|
||||
func WaitStyle(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return waitStyleWhen(ctx, args, drivers.WaitEventPresence)
|
||||
}
|
||||
|
||||
// WAIT_NO_STYLE
|
||||
// WAIT_NO_STYLE waits until a target style value disappears
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} styleNameOrSelector - Style name or CSS selector.
|
||||
// @param {String | Any} valueOrStyleName - Style value or name.
|
||||
// @param {Any | Int} [valueOrTimeout] - Style value or wait timeout.
|
||||
// @param {Int} [timeout=5000] - Wait timeout.
|
||||
func WaitNoStyle(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return waitStyleWhen(ctx, args, drivers.WaitEventAbsence)
|
||||
}
|
||||
|
@ -9,12 +9,22 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// WAIT_STYLE_ALL
|
||||
// WAIT_STYLE_ALL waits until a target style value appears on all matched elements with a given value.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} styleNameOrSelector - Style name or CSS selector.
|
||||
// @param {String | Any} valueOrStyleName - Style value or name.
|
||||
// @param {Any | Int} [valueOrTimeout] - Style value or wait timeout.
|
||||
// @param {Int} [timeout=5000] - Timeout.
|
||||
func WaitStyleAll(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return waitStyleAllWhen(ctx, args, drivers.WaitEventPresence)
|
||||
}
|
||||
|
||||
// WAIT_NO_STYLE_ALL
|
||||
// WAIT_NO_STYLE_ALL waits until a target style value disappears on all matched elements with a given value.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} styleNameOrSelector - Style name or CSS selector.
|
||||
// @param {String | Any} valueOrStyleName - Style value or name.
|
||||
// @param {Any | Int} [valueOrTimeout] - Style value or wait timeout.
|
||||
// @param {Int} [timeout=5000] - Timeout.
|
||||
func WaitNoStyleAll(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return waitStyleAllWhen(ctx, args, drivers.WaitEventAbsence)
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
)
|
||||
|
||||
// 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.
|
||||
// @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node.
|
||||
// @param {String} expression - XPath expression.
|
||||
// @return {Any} - Returns result of a given XPath expression.
|
||||
func XPath(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 2)
|
||||
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
)
|
||||
|
||||
// RegisterLib register `FS` namespace functions.
|
||||
// @namespace FS
|
||||
func RegisterLib(ns core.Namespace) error {
|
||||
return ns.
|
||||
Namespace("FS").
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Read reads from a given file.
|
||||
// @params path (String) - path to file to read from.
|
||||
// @returns data (Binary) - the read file in binary format.
|
||||
// READ reads from a given file.
|
||||
// @param {String} path - Path to file to read from.
|
||||
// @return {Binary} - File content in binary format.
|
||||
func Read(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 1, 1)
|
||||
|
||||
|
@ -10,16 +10,14 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||||
)
|
||||
|
||||
// Write writes the given data into the file.
|
||||
// @params path (String) - path to file to write into.
|
||||
// @params data (Binary) - data to write.
|
||||
// @params params (Object) optional - additional parameters:
|
||||
// * mode (String):
|
||||
// * x - Exclusive: returns an error if the file exist. It can be
|
||||
// combined with other modes
|
||||
// * a - Append: will create a file if the specified file does not exist
|
||||
// * w - Write (Default): will create a file if the specified file does not exist
|
||||
// @returns None
|
||||
// WRITE writes the given data into the file.
|
||||
// @param {String} path - File path to write into.
|
||||
// @param {Binary} data - Data to write.
|
||||
// @param {Object} [params] - additional parameters:
|
||||
// @param {String} [params.mode] - Write mode.
|
||||
// * x - Exclusive: returns an error if the file exist. It can be combined with other modes
|
||||
// * a - Append: will create a file if the specified file does not exist
|
||||
// * w - Write (Default): will create a file if the specified file does not exist
|
||||
func Write(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := validateRequiredWriteArgs(args)
|
||||
if err != nil {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// RegisterLib register `IO` namespace functions.
|
||||
// @namespace IO
|
||||
func RegisterLib(ns core.Namespace) error {
|
||||
io := ns.Namespace("IO")
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user