projectdiscovery/nuclei · error

no such element

Error message

no such element

What it means

pageElementBy resolves elements by different `by` modes; for `by: search` it calls page.Search (CDP DOM search) and if elms.First is nil — the query matched zero nodes — it returns this explicit 'no such element' error instead of rod's ErrElementNotFound.

Source

Thrown at pkg/protocols/headless/engine/page_actions.go:986

		js, err := p.getActionArg(action, "js")
		if err != nil {
			return nil, nil, err
		}
		element, err := page.ElementByJS(&rod.EvalOptions{JS: js})
		return element, nil, err
	case "search":
		query, err := p.getActionArg(action, "query")
		if err != nil {
			return nil, nil, err
		}
		elms, err := page.Search(query)
		if err != nil {
			return nil, nil, err
		}
		if elms.First != nil {
			return elms.First, nil, nil
		}
		return nil, nil, errors.New("no such element")
	default:
		selector, err := p.getActionArg(action, "selector")
		if err != nil {
			return nil, nil, err
		}
		element, err := page.Element(selector)
		return element, &selector, err
	}
}

// DebugAction enables debug action on a page.
func (p *Page) DebugAction(act *Action, out ActionData) error {
	p.instance.browser.engine.SlowMotion(5 * time.Second)
	p.instance.browser.engine.Trace(true)
	return nil
}

// SleepAction sleeps on the page for a specified duration

View on GitHub (pinned to 265b3a3dec)

Solutions

  1. Confirm the search text/selector matches in DevTools on the rendered page
  2. Add waitfor/waitidle before the search so async content is present
  3. Prefer `by: selector` with a CSS selector when the element has a stable attribute
  4. Increase page-timeout if the app renders slowly

Example fix

# before
- action: click
  by: search
  q: Submit response

# after
- action: waitidle
- action: click
  by: search
  q: Submit response
Defensive patterns

Strategy: try-catch

Try / catch

if _, _, err := p.pageElementBy(page, act); err != nil {
    if strings.Contains(err.Error(), "no such element") {
        // treat as 'page state does not match' — record and move on
        return nil
    }
    return err
}

Prevention

When it happens

Trigger: An action (click/extract/waitfor etc.) using `by: search` with a search query that matches nothing on the current page state, e.g. searching for button text that only renders after login or after async load.

Common situations: Searching for text that appears late (no preceding waitload/waitfor); search strings with typos; content inside iframes that a plain search does not reach.

Related errors


AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15). Data as JSON: /api/errors/74510a72ce5f8db1. Report an issue: GitHub.