mirror of
https://github.com/MontFerret/ferret.git
synced 2025-07-05 00:49:00 +02:00
Bugfix/e2e tests (#648)
* Fixed logger level * Fixed WAITFOR EVENT parser * Added tracing to Network Manager * Updated logging * Swtitched to value type of logger * Added tracing * Increased websocket maximum buffer size * Ignore unimportant error message * Added support of new CDP API for layouts * Switched to value type of logger * Added log level * Fixed early context cancellation * Updated example of 'click' action * Switched to val for elements lookup * Fixed unit tests * Refactored 'eval' module * Fixed SetStyle eval expression * Fixed style deletion * Updated logic of setting multiple styles
This commit is contained in:
@ -5,13 +5,14 @@ import (
|
||||
"github.com/MontFerret/ferret/pkg/drivers"
|
||||
"github.com/MontFerret/ferret/pkg/runtime/core"
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// FRAMES finds HTML frames by a given property selector.
|
||||
// Returns an empty array if frames not found.
|
||||
// @param {HTMLPage} page - HTML page.
|
||||
// @param {String} property - Property selector.
|
||||
// @param {Any} value - Property value.
|
||||
// @param {String} exp - Regular expression to match 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)
|
||||
@ -33,7 +34,11 @@ func Frames(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
}
|
||||
|
||||
propName := values.ToString(args[1])
|
||||
propValue := args[2]
|
||||
matcher, err := regexp.Compile(values.ToString(args[2]).String())
|
||||
|
||||
if err != nil {
|
||||
return values.None, err
|
||||
}
|
||||
|
||||
result, _ := frames.Find(func(value core.Value, idx int) bool {
|
||||
doc, e := drivers.ToDocument(value)
|
||||
@ -51,7 +56,7 @@ func Frames(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
return false
|
||||
}
|
||||
|
||||
return currentPropValue.Compare(propValue) == 0
|
||||
return matcher.MatchString(currentPropValue.String())
|
||||
})
|
||||
|
||||
return result, err
|
||||
|
Reference in New Issue
Block a user