Skip to content

stagehand action occasionally return two xpath which locates the same object but one of them successfully click the button while the other does not #253

@alexsiu398

Description

@alexsiu398

Before submitting an issue, please:

Environment Information

Please provide the following information to help us reproduce and resolve your issue:

Stagehand:

  • Language/SDK: Python
  • Stagehand version: 0.5.7

AI Provider:

  • Provider: gemini, cerebras
  • Model: gemini-2.0-flash, gemini-2.5-flash, gpt-oss-120b, llama-3.3-70b

Issue Description

stagehand action return two xpath locates the same object but one of them successfully click the button while the other does not

Steps to Reproduce

  1. stagehand action to click a login button
  2. check the results

Minimal Reproduction Code

import asyncio
from stagehand import Stagehand

async def main():
    stagehand = Stagehand(
        env="LOCAL",
        model_name="google/gemini-2.5-flash",
        model_api_key=os.getenv("GOOGLE_API_KEY")
    )
    await stagehand.init()
    page = stagehand.page
    
    await page.goto("https://mywebapp.com")
    
    # Act on the page
    await page.act("Click the Login button")
    await page.act("Input email abc@email.com")

    await stagehand.close()

if __name__ == "__main__":
    asyncio.run(main())

Error Messages / Log trace

correctly click the button xpath=/html/body[1]/div[1]/div[1]/div[2]/nav[1]/div[1]/div[3]/button[1]/span[1]
cannot click the button xpath=/html/body[1]/div[3]/div[1]/div[1]/div[1]/div[1]/form[1]/div[3]/button[1].

Screenshots / Videos

[Attach screenshots or videos here]

Related Issues

Are there any related issues or PRs?

  • Related to: #[issue number]
  • Duplicate of: #[issue number]
  • Blocks: #[issue number]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions