Skip to content

Unable to click checkbox #553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
BaiqingL opened this issue Mar 4, 2025 · 3 comments
Open

Unable to click checkbox #553

BaiqingL opened this issue Mar 4, 2025 · 3 comments

Comments

@BaiqingL
Copy link

BaiqingL commented Mar 4, 2025

To reproduce:

  await page.goto("https://availfinance.online/home/auth/signup.php");

  // You can pass a string directly to act
  await page.act({
    action: "scroll to the bottom of the page, and click on the I agree with terms and conditions checkbox",
    useVision: true
  });

Unable to click the terms and conditions button, fails to do so after some retries with different models (sonnet 3.7, 4o, etc)

@34892002
Copy link

34892002 commented Mar 7, 2025

const observations1 = await stagehand.page.observe({
    instruction: `找到 '[class^="index_search_"] input'这个输入框,输入关键字 小米14`,
  });
  await stagehand.page.act(observations1[0]);
  const observations2 = await stagehand.page.observe({
    instruction: `找到 '[class^="index_search_"] button' 这个按钮,点击它`,
  });
  await stagehand.page.act(observations2[0]);
  const headlines = await stagehand.page.extract({
    instruction: "提取页面的前5条新闻",
    schema: z.object({
      news: z.array(
        z.object({
          title: z.string(),
          url: z.string(),
          points: z.number(),
        })
      ),
    }),
  });
`

@BaiqingL
Copy link
Author

BaiqingL commented Mar 7, 2025

const observations1 = await stagehand.page.observe({
instruction: 找到 '[class^="index_search_"] input'这个输入框,输入关键字 小米14,
});
await stagehand.page.act(observations1[0]);
const observations2 = await stagehand.page.observe({
instruction: 找到 '[class^="index_search_"] button' 这个按钮,点击它,
});
await stagehand.page.act(observations2[0]);
const headlines = await stagehand.page.extract({
instruction: "提取页面的前5条新闻",
schema: z.object({
news: z.array(
z.object({
title: z.string(),
url: z.string(),
points: z.number(),
})
),
}),
});
`

A bit confused, is this a related issue or a different issue?

@vishesh-baghel
Copy link

I am also facing the same issue. Not sure what is wrong with this code.

export async function clickOnWarningCheckButton(page: Page) {
  const instruction =
    "Click on the only checkbox present in the modal window";
  const cachedAction = await readCache(instruction);

  if (cachedAction) {
    await page.act(cachedAction);
  } else {
    try {
      const results = await page.observe({
        instruction,
        onlyVisible: true,
        returnAction: true,
      });
      await simpleCache(instruction, results[0]);
      await page.act(results[0]);
      return true;
    } catch (error) {
      console.error("Error clicking on the checkbox:", error);
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants