grafana/k6 · error

checking is %q in viewport: unexpected type %T

Error message

checking is %q in viewport: unexpected type %T

What it means

Error "checking is %q in viewport: unexpected type %T" thrown in grafana/k6.

Source

Thrown at internal/js/modules/k6/browser/common/frame.go:1594

func (f *Frame) isInViewport(selector string, opts *FrameIsInViewportOptions) (bool, error) {
	isInViewport := func(apiCtx context.Context, handle *ElementHandle) (any, error) {
		v, err := handle.isInViewport(apiCtx, opts.Ratio)
		if errors.Is(err, ErrTimedOut) { // We don't care about timeout errors here!
			return v, nil
		}
		return v, err
	}
	act := f.newAction(
		selector, DOMElementStateAttached, opts.Strict, isInViewport, []string{}, false, withRetry, true, opts.Timeout,
	)
	v, err := call(f.ctx, act, opts.Timeout)
	if err != nil {
		return false, errorFromDOMError(err)
	}

	bv, ok := v.(bool)
	if !ok {
		return false, fmt.Errorf("checking is %q in viewport: unexpected type %T", selector, v)
	}

	return bv, nil
}

// ID returns the frame id.
func (f *Frame) ID() string {
	f.propertiesMu.RLock()
	defer f.propertiesMu.RUnlock()

	return f.id.String()
}

// Locator creates and returns a new locator for this frame.
func (f *Frame) Locator(selector string, opts *LocatorOptions) *Locator {
	f.log.Debugf("Frame:Locator", "fid:%s furl:%q selector:%q opts:%+v", f.ID(), f.URL(), selector, opts)

	return NewLocator(f.ctx, opts, selector, f, f.log)

View on GitHub (pinned to 93accf6570)

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/frame.go:1594 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/bbdc3af23c473c19. Report an issue: GitHub.