Closed ankur22 closed 10 months ago
Nice catch!
It doesn't seem related to Locator
, but to ElementHandle
:
It should call Mouse.dblClick()
:smile:
@ankur22 Thanks Ankur for helping me find the problems in the locator tests 🙇
@imiric No, it's not because of not calling Mouse.dblClick
. Because some locator tests are incorrect 🤦 I'll send a PR.
Ankur, shouldn't the server needs to listen for the dblclick
event here instead of the click
event? I've changed it to dblclick
and it worked.
I've then used the click()
method in the script instead (while the server listens for the dblclick
event). Expectedly, it did nothing (fortunately!). This validates that our dblclick()
works.
@inancgumus I wasn't clear in the original description. The dblclick
action in xk6-browser doesn't match the behaviour in playwright.
Playwright script:
const { test, chromium } = require('@playwright/test');
test.describe('Editing', () => {
test('Type login creds', async () => {
const browser = await chromium.launch({ headless: false });
const ctx = await browser.newContext();
const page = await ctx.newPage();
await page.goto("https://test.k6.io/browser.php");
const l = page.locator('#counter-button');
await new Promise(resolve => setTimeout(resolve, 1000));
l.dblclick();
await new Promise(resolve => setTimeout(resolve, 10000));
await browser.close();
});
});
The outcome is that the counter
on the test page is 2
. Whereas the xk6-browser test script (now amended in the original description) results in 1
.
I'm not sure what you mean here, could you elaborate a bit?:
Ankur, shouldn't the server needs to listen for the dblclick event here instead of the click event? I've changed it to dblclick and it worked.
I've then used the click() method in the script instead (while the server listens for the dblclick event). Expectedly, it did nothing (fortunately!). This validates that our dblclick() works.
TODO:
xk6-browser docs imply that this
dblclick
issue is about locators, however, it's the behavior in our extension in general.Tested against: https://github.com/grafana/xk6-browser/commit/dbede120c63df43995813a847a25b0e66e289592
The method
dblclick
onlocator
only clicks once.In the below code it works against
localhost:8080
, which is a test server that can be found here with instructions on how to run it locally: https://github.com/ankur22/testserver.I was expecting the counter on this test page to go up to
2
but it only went up to1
. When testing with PW i was able to get the expected count of2
.