mirror of
https://github.com/MontFerret/ferret.git
synced 2025-03-21 21:47:43 +02:00
* Added remote type reference resolver * Added support of XPath query selector * Added CDP e2e testss covering XPath integration * Added additional CDP e2e tests covering XPath integration * Added type check to QuerySelector casting function * Fixed XPath e2e tests * Fixed vuln issue * Added support of XPath selectors to http driver * Added e2e tests for XPAth
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package html
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/MontFerret/ferret/pkg/drivers"
|
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
|
"github.com/MontFerret/ferret/pkg/runtime/values"
|
|
)
|
|
|
|
// 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 {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)
|
|
|
|
if err != nil {
|
|
return values.None, err
|
|
}
|
|
|
|
el, err := drivers.ToElement(args[0])
|
|
|
|
if err != nil {
|
|
return values.None, err
|
|
}
|
|
|
|
if len(args) == 1 {
|
|
return values.True, el.Hover(ctx)
|
|
}
|
|
|
|
selector, err := drivers.ToQuerySelector(args[1])
|
|
|
|
if err != nil {
|
|
return values.None, err
|
|
}
|
|
|
|
return values.True, el.HoverBySelector(ctx, selector)
|
|
}
|