diff --git a/e2e/tests/el_element_exists_d.fql b/e2e/tests/el_element_exists_d.fql index ac2be8d7..05668e5c 100644 --- a/e2e/tests/el_element_exists_d.fql +++ b/e2e/tests/el_element_exists_d.fql @@ -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) \ No newline at end of file +RETURN EXPECT(expectedP + expectedN, actualP + expectedN) diff --git a/pkg/drivers/http/element.go b/pkg/drivers/http/element.go index 2f7e252d..710874f0 100644 --- a/pkg/drivers/http/element.go +++ b/pkg/drivers/http/element.go @@ -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 }