1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-06-23 00:28:10 +02:00
* Renamed DOCUMENT to PAGE

* Added PageLoadParams

* Added PageLoadParams

* Renamed LoadPageParams -> PageLoadParams

* Added support for context.Done() (#201)

* Bug/#189 operators precedence (#202)

* Fixed math operators precedence

* Fixed logical operators precedence

* Fixed array operator

* Added support for parentheses to enforce a different operator evaluation order

* Feature/#200 drivers (#209)

* Added new interfaces

* Renamed dynamic to cdp driver

* Renamed drivers

* Added ELEMENT_EXISTS function (#210)

* Renamed back PAGE to DOCUMENT (#211)

* Added Getter and Setter interfaces
This commit is contained in:
Tim Voronov
2018-12-21 23:14:41 -05:00
committed by GitHub
parent 6bc4b3e0e3
commit 5620be211c
92 changed files with 2953 additions and 1656 deletions

View File

@ -1,7 +1,10 @@
package html
import (
"context"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
"github.com/pkg/errors"
)
@ -16,12 +19,13 @@ func NewLib() map[string]core.Function {
"CLICK": Click,
"CLICK_ALL": ClickAll,
"DOCUMENT": Document,
"DOCUMENT_PARSE": DocumentParse,
"DOWNLOAD": Download,
"ELEMENT": Element,
"ELEMENT_EXISTS": ElementExists,
"ELEMENTS": Elements,
"ELEMENTS_COUNT": ElementsCount,
"HOVER": Hover,
"HTML_PARSE": Parse,
"INNER_HTML": InnerHTML,
"INNER_HTML_ALL": InnerHTMLAll,
"INNER_TEXT": InnerText,
@ -43,3 +47,31 @@ func NewLib() map[string]core.Function {
"WAIT_NAVIGATION": WaitNavigation,
}
}
func ValidateDocument(ctx context.Context, value core.Value) (core.Value, error) {
err := core.ValidateType(value, core.HTMLDocumentType, core.StringType)
if err != nil {
return values.None, err
}
var doc values.DHTMLDocument
var ok bool
if value.Type() == core.StringType {
buf, err := Document(ctx, value, values.NewBoolean(true))
if err != nil {
return values.None, err
}
doc, ok = buf.(values.DHTMLDocument)
} else {
doc, ok = value.(values.DHTMLDocument)
}
if !ok {
return nil, ErrNotDynamic
}
return doc, nil
}