1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-07-05 00:49:00 +02:00

Added errors to ClickX methods and added existence check (#341)

* Added errors to ClickX methods and added existence check

* Fixes

* Return None from Iterator when an error occurs
This commit is contained in:
Tim Voronov
2019-07-26 13:22:06 -04:00
committed by GitHub
parent 7e6b3bf15d
commit b323a984cc
10 changed files with 78 additions and 62 deletions

View File

@ -26,7 +26,7 @@ func Click(ctx context.Context, args ...core.Value) (core.Value, error) {
return values.False, err
}
return el.Click(ctx)
return values.True, el.Click(ctx)
}
// CLICK(doc, selector)
@ -36,7 +36,16 @@ func Click(ctx context.Context, args ...core.Value) (core.Value, error) {
return values.False, err
}
selector := args[1].String()
selector := values.ToString(args[1])
exists, err := doc.ExistsBySelector(ctx, selector)
return doc.ClickBySelector(ctx, values.NewString(selector))
if err != nil {
return values.False, err
}
if !exists {
return exists, nil
}
return exists, doc.ClickBySelector(ctx, selector)
}