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

Merge pull request #390 from gyy52380/master

Bugfixes in http driver functions that utilize goquery
This commit is contained in:
Tim Voronov 2019-10-07 17:11:36 -04:00 committed by GitHub
commit bb210fbc07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View File

@ -1,5 +1,5 @@
LET url = @dynamic
LET doc = DOCUMENT(url)
LET doc = DOCUMENT(url, true)
LET el = ELEMENT(doc, "#root")
@ -9,4 +9,4 @@ LET actualP = ELEMENT_EXISTS(el, '.jumbotron')
LET expectedN = FALSE
LET actualN = ELEMENT_EXISTS(el, '.foo-bar')
RETURN EXPECT(expectedP + expectedN, actualP + expectedN)
RETURN EXPECT(expectedP + expectedN, actualP + expectedN)

View File

@ -293,7 +293,7 @@ func (el *HTMLElement) GetChildNode(_ context.Context, idx values.Int) (core.Val
func (el *HTMLElement) QuerySelector(_ context.Context, selector values.String) (core.Value, error) {
selection := el.selection.Find(selector.String())
if selection == nil {
if selection.Length() == 0 {
return values.None, nil
}
@ -309,7 +309,7 @@ func (el *HTMLElement) QuerySelector(_ context.Context, selector values.String)
func (el *HTMLElement) QuerySelectorAll(_ context.Context, selector values.String) (*values.Array, error) {
selection := el.selection.Find(selector.String())
if selection == nil {
if selection.Length() == 0 {
return values.NewArray(0), nil
}
@ -374,7 +374,7 @@ func (el *HTMLElement) XPath(_ context.Context, expression values.String) (core.
func (el *HTMLElement) SetInnerHTMLBySelector(_ context.Context, selector, innerHTML values.String) error {
selection := el.selection.Find(selector.String())
if selection == nil {
if selection.Length() == 0 {
return drivers.ErrNotFound
}
@ -386,7 +386,7 @@ func (el *HTMLElement) SetInnerHTMLBySelector(_ context.Context, selector, inner
func (el *HTMLElement) GetInnerHTMLBySelector(_ context.Context, selector values.String) (values.String, error) {
selection := el.selection.Find(selector.String())
if selection == nil {
if selection.Length() == 0 {
return values.EmptyString, drivers.ErrNotFound
}
@ -427,7 +427,7 @@ func (el *HTMLElement) GetInnerHTMLBySelectorAll(_ context.Context, selector val
func (el *HTMLElement) GetInnerTextBySelector(_ context.Context, selector values.String) (values.String, error) {
selection := el.selection.Find(selector.String())
if selection == nil {
if selection.Length() == 0 {
return values.EmptyString, drivers.ErrNotFound
}
@ -437,7 +437,7 @@ func (el *HTMLElement) GetInnerTextBySelector(_ context.Context, selector values
func (el *HTMLElement) SetInnerTextBySelector(_ context.Context, selector, innerText values.String) error {
selection := el.selection.Find(selector.String())
if selection == nil {
if selection.Length() == 0 {
return drivers.ErrNotFound
}
@ -460,7 +460,7 @@ func (el *HTMLElement) GetInnerTextBySelectorAll(_ context.Context, selector val
func (el *HTMLElement) CountBySelector(_ context.Context, selector values.String) (values.Int, error) {
selection := el.selection.Find(selector.String())
if selection == nil {
if selection.Length() == 0 {
return values.ZeroInt, nil
}
@ -468,9 +468,9 @@ func (el *HTMLElement) CountBySelector(_ context.Context, selector values.String
}
func (el *HTMLElement) ExistsBySelector(_ context.Context, selector values.String) (values.Boolean, error) {
selection := el.selection.Closest(selector.String())
selection := el.selection.Find(selector.String())
if selection == nil {
if selection.Length() == 0 {
return values.False, nil
}