Skip to content

MrHaikuSwan/stagehand-bug-text-node-selection

Repository files navigation

Text Node Selection Reproduction

This repository reproduces an issue with erroneous text node selection in Stagehand.

Overview

This is a minimal reproduction case that demonstrates text node selection behavior when Stagehand interacts with a simple HTML page containing clickable elements.

Reproduction Steps

  1. Start the server serving the test case HTML file in one terminal:

    npm run serve
  2. Run the Stagehand script in a second terminal:

    npm start

Behavior

Expected: Stagehand should successfully identify and click the "Card" element, triggering the JavaScript alert.

Actual: Stagehand fails to click on the "Card" element, eventually timing out.

The logged output (stored in stagehand.log for convenience) shows that the LLM is shown an accessibility tree with the text shown at the StaticText level, which causes the following action to be attempted:

{
  category: 'action',
  message: 'performing playwright method',
  level: 2,
  auxiliary: {
    xpath: {
      value: '/html[1]/body[1]/div[1]/div[1]/text()[1]',
      type: 'string'
    },
    method: { value: 'click', type: 'string' }
  }
}

This doesn't work because the XPath ends in /text()[1], but it would work if the XPath targeted the div instead.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published