Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare Locator for async migration #1330

Merged
merged 25 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2aa2a32
Refactor Locator.Dblclick to return err
inancgumus May 13, 2024
2354f14
Refactor Locator.Check to return err
inancgumus May 13, 2024
f6fbf0f
Refactor locator.Uncheck to return err
inancgumus May 13, 2024
6196eec
Refactor Locator.IsChecked to return err
inancgumus May 13, 2024
8a1f35c
Refactor Locator.IsEditable to return err
inancgumus May 13, 2024
2b0e941
Refactor Locator.IsEnabled to return err
inancgumus May 13, 2024
bf6e4df
Refactor Locator.IsDisabled to return err
inancgumus May 13, 2024
acd1f2f
Refactor Locator.IsVisible to return err
inancgumus May 13, 2024
1d6bd5b
Refactor Locator.IsHidden to return err
inancgumus May 13, 2024
d2a2204
Refactor Locator.Fill to return err
inancgumus May 13, 2024
671f0e1
Refactor Locator.Focus to return err
inancgumus May 13, 2024
bc9daca
Refactor Locator.GetAttribute to return err
inancgumus May 13, 2024
bab1b4c
Refactor Locator.InnerHTML to return err
inancgumus May 14, 2024
06cfcd0
Refactor Locator.InnerText to return err
inancgumus May 14, 2024
cefdc6b
Refactor Locator.TextContent to return err
inancgumus May 14, 2024
4df9d5c
Refactor Locator.InputValue to return err
inancgumus May 14, 2024
e2b6ffc
Refactor Locator.SelectOption to return err
inancgumus May 14, 2024
77fe038
Refactor Locator.Press to return err
inancgumus May 14, 2024
22a1c4e
Refactor Locator.Type to return err
inancgumus May 14, 2024
bf473ec
Refactor Locator.Hover to return err
inancgumus May 14, 2024
5f36d18
Refactor Locator.DispatchEvent to return err
inancgumus May 14, 2024
0ddbb61
Refactor Locator.WaitFor to return err
inancgumus May 14, 2024
84d64e9
Refactor Locator tests to return err
inancgumus May 14, 2024
668c3bb
Fix tap mapping tests
inancgumus May 14, 2024
8e45ae6
Refactor TestLocatorElementState to check errs
inancgumus May 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion browser/mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ type locatorAPI interface {
Check(opts goja.Value) error
Uncheck(opts goja.Value) error
IsChecked(opts goja.Value) (bool, error)
IsEditable(opts goja.Value) bool
IsEditable(opts goja.Value) (bool, error)
IsEnabled(opts goja.Value) bool
IsDisabled(opts goja.Value) bool
IsVisible(opts goja.Value) bool
Expand Down
8 changes: 4 additions & 4 deletions common/locator.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,19 @@ func (l *Locator) isChecked(opts *FrameIsCheckedOptions) (bool, error) {

// IsEditable returns true if the element matches the locator's
// selector and is Editable. Otherwise, returns false.
func (l *Locator) IsEditable(opts goja.Value) bool {
func (l *Locator) IsEditable(opts goja.Value) (bool, error) {
l.log.Debugf("Locator:IsEditable", "fid:%s furl:%q sel:%q opts:%+v", l.frame.ID(), l.frame.URL(), l.selector, opts)

copts := NewFrameIsEditableOptions(l.frame.defaultTimeout())
if err := copts.Parse(l.ctx, opts); err != nil {
k6ext.Panic(l.ctx, "parsing is editable options: %w", err)
return false, fmt.Errorf("parsing is editable options: %w", err)
}
editable, err := l.isEditable(copts)
if err != nil {
k6ext.Panic(l.ctx, "checking is %q editable: %w", l.selector, err)
return false, fmt.Errorf("checking is %q editable: %w", l.selector, err)
}

return editable
return editable, nil
}

// isEditable is like IsEditable but takes parsed options and does not
Expand Down
9 changes: 7 additions & 2 deletions tests/locator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func TestLocatorElementState(t *testing.T) {
{
"readOnly",
`() => document.getElementById('inputText').readOnly = true`,
func(l *common.Locator) bool { return l.IsEditable(nil) },
func(l *common.Locator) bool { resp, _ := l.IsEditable(nil); return resp },
ankur22 marked this conversation as resolved.
Show resolved Hide resolved
},
{
"visible",
Expand Down Expand Up @@ -493,7 +493,12 @@ func TestLocatorElementState(t *testing.T) {
},
},
{
"IsEditable", func(l *common.Locator, tb *testBrowser) { l.IsEditable(timeout(tb)) },
"IsEditable", func(l *common.Locator, tb *testBrowser) {
if _, err := l.IsEditable(timeout(tb)); err != nil {
// TODO: remove panic and update tests when all locator methods return error.
panic(err)
}
},
},
{
"IsEnabled", func(l *common.Locator, tb *testBrowser) { l.IsEnabled(timeout(tb)) },
Expand Down