grafana/k6 · error
getting inner HTML of
Error message
getting inner HTML of %q: %w
What it means
Wrapped failure from Frame.innerHTML while retrieving the serialized inner HTML of the element matched by the locator's selector (strict mode forced). Fires when the selector matches zero or multiple elements, the node is detached, or the CDP evaluation of the innerHTML property fails.
Solutions
- Use a unique selector satisfying strict mode
- Wait for the element and its content to render before reading inner HTML
- Verify the frame is not navigating away during the read
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/locator.go:459 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/4c84f2321b8f0341.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/locator.go:459
}
// FrameLocator creates a frame locator for an iframe matching the given selector
// within the current locator's scope.
func (l *Locator) FrameLocator(selector string) *FrameLocator {
l.log.Debugf("Locator:FrameLocator", "selector:%q childSelector:%q", l.selector, selector)
return l.Locator(selector, nil).ContentFrame()
}
// InnerHTML returns the element's inner HTML that matches
// the locator's selector with strict mode on.
func (l *Locator) InnerHTML(opts *FrameInnerHTMLOptions) (string, error) {
l.log.Debugf("Locator:InnerHTML", "fid:%s furl:%q sel:%q opts:%+v", l.frame.ID(), l.frame.URL(), l.selector, opts)
opts.Strict = true
s, err := l.frame.innerHTML(l.selector, opts)
if err != nil {
return "", fmt.Errorf("getting inner HTML of %q: %w", l.selector, err)
}
return s, nil
}
// InnerText returns the element's inner text that matches
// the locator's selector with strict mode on.
func (l *Locator) InnerText(opts *FrameInnerTextOptions) (string, error) {
l.log.Debugf("Locator:InnerText", "fid:%s furl:%q sel:%q opts:%+v", l.frame.ID(), l.frame.URL(), l.selector, opts)
opts.Strict = true
s, err := l.frame.innerText(l.selector, opts)
if err != nil {
return "", fmt.Errorf("getting inner text of %q: %w", l.selector, err)
}
return s, nil
}View on GitHub (pinned to 01ffac6f24)