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

#26 implemented INPUT

This commit is contained in:
Tim Voronov 2018-09-27 19:24:58 -04:00
parent 8b2e210317
commit f43d6fe870
2 changed files with 15 additions and 16 deletions

View File

@ -1,7 +1,7 @@
LET g = DOCUMENT("https://www.google.com/", true)
LET inputBox = ELEMENT(g, 'input[name="q"]')
INPUT(inputBox, "ferrer")
INPUT(inputBox, "ferret")
LET searchBtn = ELEMENT(g, 'input[name="btnK"]')
@ -9,16 +9,17 @@ CLICK(searchBtn)
WAIT_NAVIGATION(g)
LET result = ELEMENTS(g, '.g')
LOG(result ? 'element' : 'no element')
RETURN result ? (
LET result = (
FOR result IN ELEMENTS(g, '.g')
LOG('iterate')
RETURN {
title: ELEMENT(result, 'h3 > a'),
description: ELEMENT(result, '.st'),
url: ELEMENT(result, 'cite')
}
) : 'no results'
RETURN {
title: ELEMENT(result, 'h3 > a'),
description: ELEMENT(result, '.st'),
url: ELEMENT(result, 'cite')
}
)
RETURN (
FOR i IN result
FILTER i.title != NONE
RETURN i
)

View File

@ -5,6 +5,7 @@ import (
"context"
"crypto/sha512"
"encoding/json"
"fmt"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
"github.com/MontFerret/ferret/pkg/stdlib/html/driver/common"
@ -161,9 +162,6 @@ func (el *HtmlElement) Type() core.Type {
}
func (el *HtmlElement) MarshalJSON() ([]byte, error) {
el.Lock()
defer el.Unlock()
val, err := el.innerText.Value()
if err != nil {