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 ElementHandle for async migration #1335

Merged
merged 32 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
03a7066
Fix BoundingBox mapping
inancgumus May 15, 2024
a1b9955
Refactor ElementHandle.Check to return err
inancgumus May 15, 2024
b92934c
Refactor ElementHandle.Uncheck to return err
inancgumus May 15, 2024
25b8381
Refactor ElementHandle.Dblclick to return err
inancgumus May 15, 2024
893cc77
Refactor ElementHandle.Fill to return err
inancgumus May 15, 2024
65d5eb7
Refactor ElementHandle.DispatchEvent to return err
inancgumus May 15, 2024
3135ca9
Refactor ElementHandle.Focus to return err
inancgumus May 15, 2024
5be5fcd
Refactor ElementHandle.GetAttribute to return err
inancgumus May 15, 2024
f362eea
Refactor ElementHandle.Hover to return err
inancgumus May 15, 2024
6a32c24
Refactor ElementHandle.InnerHTML to return err
inancgumus May 15, 2024
a5ca7d2
Refactor ElementHandle.InnerText to return err
inancgumus May 15, 2024
6982dad
Refactor ElementHandle.InputValue to return err
inancgumus May 15, 2024
4c00598
Fix forgotten keyboard tests for error checks
inancgumus May 15, 2024
795a56c
Refactor ElementHandle.IsChecked to return err
inancgumus May 15, 2024
e28d48a
Refactor ElementHandle.IsDisabled to return err
inancgumus May 15, 2024
c4d6941
Refactor ElementHandle.IsEditable to return err
inancgumus May 15, 2024
e914ee4
Refactor ElementHandle.IsEnabled to return err
inancgumus May 15, 2024
db1849e
Refactor ElementHandle.IsHidden to return err
inancgumus May 15, 2024
2ba400d
Refactor ElementHandle.IsVisible to return err
inancgumus May 15, 2024
ab0f1cc
Refactor ElementHandle.Press to return err
inancgumus May 15, 2024
bc6adc1
Remove applySlowMo from QueryAll
inancgumus May 15, 2024
9bd5014
Refactor ElementHandle.Screenshot to return err
inancgumus May 15, 2024
befc6da
Refactor ElementHandle.ScrollIntoViewIfNeeded to return err
inancgumus May 15, 2024
efab80d
Refactor ElementHandle.SelectOptions to return err
inancgumus May 15, 2024
c011e5b
Refactor ElementHandle.SelectText to return err
inancgumus May 15, 2024
d28d6de
Refactor ElementHandle.SetInputFiles for consistency
inancgumus May 15, 2024
7fd4406
Refactor ElementHandle.TextContent to return err
inancgumus May 15, 2024
1164ef2
Refactor ElementHandle.Type to return err
inancgumus May 15, 2024
4aa7023
Fix WaitForElementState mapping API
inancgumus May 15, 2024
b1d4c4a
Refactor ElementHandle.WaitForElementState to return err
inancgumus May 15, 2024
c4e6994
Refactor ElementHandle.Query to return err
inancgumus May 15, 2024
5c968cb
Refactor errorFromDOMError to return err
inancgumus May 15, 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 @@ -432,7 +432,7 @@ type elementHandleAPI interface {
Focus() error
GetAttribute(name string) (any, error)
Hover(opts goja.Value) error
InnerHTML() string
InnerHTML() (string, error)
InnerText() string
InputValue(opts goja.Value) string
IsChecked() bool
Expand Down
20 changes: 13 additions & 7 deletions common/element_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,21 +870,27 @@ func (h *ElementHandle) Hover(opts goja.Value) error {
}

// InnerHTML returns the inner HTML of the element.
func (h *ElementHandle) InnerHTML() string {
fn := func(apiCtx context.Context, handle *ElementHandle) (any, error) {
func (h *ElementHandle) InnerHTML() (string, error) {
innerHTML := func(apiCtx context.Context, handle *ElementHandle) (any, error) {
return handle.innerHTML(apiCtx)
}
opts := NewElementHandleBaseOptions(h.defaultTimeout())
actFn := h.newAction([]string{}, fn, opts.Force, opts.NoWaitAfter, opts.Timeout)
v, err := call(h.ctx, actFn, opts.Timeout)
innerHTMLAction := h.newAction(
[]string{}, innerHTML, opts.Force, opts.NoWaitAfter, opts.Timeout,
)
v, err := call(h.ctx, innerHTMLAction, opts.Timeout)
if err != nil {
k6ext.Panic(h.ctx, "getting element's inner HTML: %w", err)
return "", fmt.Errorf("getting element's inner HTML: %w", err)
}

applySlowMo(h.ctx)

// TODO: handle error
s, ok := v.(string)
if !ok {
return "", fmt.Errorf("unexpected type %T (expecting string)", v)
inancgumus marked this conversation as resolved.
Show resolved Hide resolved
}

return v.(string) //nolint:forcetypeassert
return s, nil
}

// InnerText returns the inner text of the element.
Expand Down