Rayrun
โ† Back to Discord Forum

Playwright recorder registers double clicks instead of single clicks.

I am using Playwright to test my 3D Babylonjs project. My website has different functionalities when single-clicking and double-clicking. When I record a test through Codegen, vscode or Chrome extension, the recording browser takes single clicks as double clicks because I get the undesired functionality when recording the tests. This is getting frustrating as I cannot find a solution for this. (this stops happening as soon as I stop recording the tests)

This thread is trying to answer question "Why does the Playwright recorder register single clicks as double clicks during testing of a 3D Babylonjs project, and how can this be resolved?"

41 replies
.aleksandaraleksandrov
.aleksandaraleksandrov

Hello zeroan,

the only thing I can think of when the codegen writes the line for click(), you just redo it as a dblclick()

I don't want it to double click, I want a single click but the recording even with .click automates and clicks twice on my website

.aleksandaraleksandrov
.aleksandaraleksandrov

then edit the dblclick() to a click() ๐Ÿ™‚

on the code it is still a click()

and it then still doubkle clicks on my website. that is the real issue. sorry for replying late. I was on vacation for a bit

ill share a screenshot hold on

so the clicks on any html element is not double clicking. but im trying to create my own custom testing suite with test logic for testing babylonJs 3d canvas. which is not directly accessible by playwright as u can see. its in x, y coords inside the canvas object. Im trying to find a fix for this very particular thing.

tphillips8117

the website might be registering two different calls to click as a double click.

tphillips8117

try adding an explicit wait between your clicks

tphillips8117

(note that the delay parameter is the time between mouse down and mouse up, not the time to wait after the click)

@tphillips8117: oh i was not aware of that. with explicit wait (timeout of 1 sec between each click) it doesnt call twice. but im facing this double click issue while recording.

oh i was not aware of that. with explicit wait (timeout of 1 sec between each click) it doesnt call twice. but im facing this double click issue while recording.

i think i found the issue to be maybe playwright is rounding the x and y positions to integers and my website is clicking on the floats and integers both.

im still not sure.

this is making recording tests really tough

tphillips8117

If you slow down while recording does that affect it?

yes if i debug and theres delay then it does not click twice

not while recording tho

ill send a recording of the issue

as u can see before i start recording the tests, it is not firing 2 events. but when i start recording theres some issue and it starts clicking twice. u can see it clicks. where the line ends + at cursor location. making 2 lines. this makes recording reliable tests extremely hard for me

tphillips8117

It looks like you're using a third-party chrome plugin to do you recording What happens if you record using Playwright's official plugin for vscode? Also try using one of Playwright's bundled browsers?

same thing

just used this extension to show both before and after easier

can we get on call maybe?

ive tried all ways to record

tphillips8117

Can't get on a call unfortunately ๐Ÿ˜ฆ I am at work all day

ohh thats fine

I really need to get this figured out asap

is this a playwright issue with canvas or an issue w my app. i cant figure that out

tphillips8117

I wish I could try it out on my PC for myself

tphillips8117

would be interesting to see what's going on ๐Ÿ™‚

u can just go and sign up to snaptrude for free and try it out there

sign up on the top right

i have just gone thru some other websitesthat use a babylonjs canvas to see if this issue persists and yes this is happening on every website thats using abylonjs as a 3d tool within their website.

so now the question is how would i edit/configure playwrights recorder to behave as i wan it to

I thought a YouTube video player would be a good example of a popular site that playwright would've had to fix as a non-HTML element on a website. and my suspicions were right. playwright adds a delay like I would manually when I would debug my code. so when I interact with the player, it highlights the player in red twice and then interacts with the player with roughly 1 sec of delay. I would want the recorder to introduce a similar kind of delay or whatever u use on youtubes player to my website as well. how would i ask the dev community to help me out with this?

tphillips8117

it definitely sounds like you should raise a bug on Playwright's github

alright thanks!!

Answer

Dealing with Double Clicks in Playwright Test Recording

You might have noticed that sometimes Playwright registers single clicks as double clicks when recording tests. This can be due to various factors like the timing of the click action or the sensitivity of the mouse. But don't worry, there's a way to handle this.

Playwright provides a force option that you can use to disable non-essential actionability checks. Here's how you can use it:

await page.click(selector, { force: true });

With this, Playwright won't check if the target element actually receives click events. It's a handy trick when you want to simulate a single click without triggering any additional actions or event listeners associated with double-click behavior.

But remember, use this judiciously. It's generally better to rely on Playwright's default behavior of performing thorough actionability checks for more accurate and reliable test recordings.

So, next time you find single clicks being registered as double clicks during test recording with Playwright, just use the force option with the page.click() method. This will let you simulate a single click without triggering any additional actions or event listeners associated with double-click behavior.

For more tips and tricks on mastering Playwright, check out our blog post: Mastering Playwright: Best Practices for Web Automation with the Page Object Model.

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.