grafana/k6 · error

no valid href attribute value found on element '%s' in respo

Error message

no valid href attribute value found on element '%s' in response '%s'

What it means

ClickLink found a matching element, but its 'href' attribute is absent, so there is no URL to navigate to. The element matched the selector yet is not a usable link — e.g. an <a> used as a placeholder or a non-anchor element.

Source

Thrown at js/modules/k6/http/response.go:263

				selector = params.Get(k).String()
			case "params":
				requestParams = params.Get(k)
			}
		}
	}

	responseURL, err := url.Parse(res.URL)
	if err != nil {
		common.Throw(rt, err)
	}

	link := res.HTML(selector)
	if link.Size() == 0 {
		common.Throw(rt, fmt.Errorf("no element found for selector '%s' in response '%s'", selector, res.URL))
	}
	hrefAttr := link.Attr("href")
	if hrefAttr == sobek.Undefined() {
		errmsg := fmt.Errorf("no valid href attribute value found on element '%s' in response '%s'", selector, res.URL)
		common.Throw(rt, errmsg)
	}
	hrefURL, err := url.Parse(hrefAttr.String())
	if err != nil {
		common.Throw(rt, err)
	}
	requestURL := responseURL.ResolveReference(hrefURL)

	return res.client.Request(http.MethodGet, rt.ToValue(requestURL.String()), sobek.Undefined(), requestParams)
}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Target an element that actually has an href attribute (a real hyperlink)
  2. If the navigation is JavaScript-driven, issue the request directly with http.get() instead of ClickLink
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at js/modules/k6/http/response.go:263 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/560721c644e943cd. Report an issue: GitHub.