grafana/k6 · error
parsing get attribute options
Error message
parsing get attribute options: %w
What it means
Thrown synchronously when the options argument to locator.getAttribute(name, opts) fails to parse. The mapping (locator_mapping.go:218-222) builds FrameBaseOptions with the locator timeout and wraps Parse errors as "parsing get attribute options: %w". Since FrameBaseOptions.Parse only reads strict/timeout with coercing accessors that tolerate ordinary type mistakes, an actual failure comes from sobek raising during ToObject/Keys/Get — i.e. a throwing getter, a Proxy trap, or a throwing valueOf on the values.
Solutions
- Pass a plain literal: locator.getAttribute('href', { timeout: 3000 }) or omit options
- Materialize dynamic values before the call
- Avoid Proxies/accessors on options handed to the browser module
- Wrap in try/catch to fail the iteration cleanly
Example fix
// before
await locator.getAttribute('href', optsProxy); // get trap throws
// after
const opts = { timeout: optsProxy.timeout };
await locator.getAttribute('href', opts); Defensive patterns
Strategy: try-catch
Type guard
function isPlainBaseOptions(o) {
return o == null || (typeof o === 'object' &&
(o.timeout === undefined || typeof o.timeout === 'number') &&
(o.strict === undefined || typeof o.strict === 'boolean'));
} Try / catch
try {
const href = await locator.getAttribute('href', opts);
} catch (e) {
throw new Error(`getAttribute failed (check the options object, not the attribute name): ${e}`);
} Prevention
- Pass { timeout: ms } as a plain literal or omit options
- Validate config objects before handing them to browser APIs
- Avoid tracing Proxies on arguments
When it happens
Trigger: Options object with a getter for timeout/strict that raises; Proxy options whose get or ownKeys traps throw; a timeout value with a throwing toPrimitive during integer coercion.
Common situations: Attribute-fetch helpers that accept config objects with validation getters; argument tracing Proxies; passing exotic objects where a plain literal is expected.
Related errors
- parsing fill options
- parsing focus options
- parsing hover options
- parsing inner HTML options
- parsing inner text options
AI-assisted analysis of grafana/k6@8d06114777 (2026-09-14).
Data as JSON: /api/errors/059b216195916d8f.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/browser/locator_mapping.go:222
}))
},
"first": func() *sobek.Object {
ml := mapLocator(vu, lo.First())
return rt.ToValue(ml).ToObject(rt)
},
"focus": func(opts sobek.Value) (*sobek.Promise, error) {
copts := common.NewFrameBaseOptions(lo.Timeout())
if err := parseFrameBaseOptions(copts, rt, opts); err != nil {
return nil, fmt.Errorf("parsing focus options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, lo.Focus(copts) //nolint:wrapcheck
}), nil
},
"getAttribute": func(name string, opts sobek.Value) (*sobek.Promise, error) {
copts := common.NewFrameBaseOptions(lo.Timeout())
if err := parseFrameBaseOptions(copts, rt, opts); err != nil {
return nil, fmt.Errorf("parsing get attribute options: %w", err)
}
return promise(vu, func() (any, error) {
s, ok, err := lo.GetAttribute(name, copts)
if err != nil {
return nil, err //nolint:wrapcheck
}
if !ok {
return nil, nil
}
return s, nil
}), nil
},
"getByAltText": func(alt sobek.Value, opts sobek.Value) (*sobek.Object, error) {
if k6common.IsNullish(alt) {
return nil, errors.New("missing required argument 'altText'")
}
palt, popts := parseGetByBaseOptions(vu.Context(), alt, false, opts)
View on GitHub (pinned to 8d06114777)