UI testing retool App - Can't click button

Hi all,

I'm using playwright to test my retool app.

My app has a form with a submit button at the bottom. Using playwright, I can select the button with the following line (Java):

Locator submitButton = page.getByTestId("Component::Button-submitButton--0").locator("button");

I know I'm selecting the correct button (I inspected the returned element and printed debug statements too). However, when I click the button:

submitButton.click();

Although the button gets highlighted, it is not clicked. I tried forcing the click:

submitButton.click(new Locator.ClickOptions().setForce(true));

but had no luck.

I'm starting to wonder if the fact that the button belongs to a form has something to do with this problem.

Have you encountered this situation or have a clue how to solve it?

P.S.: The button is active and visible.

Hi Javi,

I'm pretty sure the standard button doesn't offer a click() method; it's not listed in the methods in the Button docs:

And when I try it in the console in a test app, i get an error about it not being a function:

Screenshot 2024-12-04 at 11.21.30 AM

(I'm surprised it's highlighting the button when you try that call in your code, but that might be incidental or an unintended side-effect.)

I vaguely recall seeing here in the forums or other docs that this is expected, as the button is meant to be non-programmatic and only truly clicked via user action, but I couldn't find any trace of that.

I'm not familiar with Playwright directly, but is it possible to just call the button's click event handler(s) directly? (I realize that wouldn't be a true exercise of the UI/app, but it might suffice for your case!)

1 Like

Hi dguzzo,

The click method happens on playwright, but there is something about buttons in retool that is blocking the click. That's why I wanted to know if someone has encountered this problem while trying to test an app.

makes sense! hopefully someone here can provide an answer :crossed_fingers:

Hello @Javi_V,

Sorry for the confusion, we should do a better job adding this into our documentation to explain that the button.click method won't work as pointed out by @dguzzo.

However you can still execute tests using playwright, you will just need to replace await button.click() with

await button.focus(); await page.keyboard.press("Enter") as outlined in this forum post on a similar topic!

1 Like