Skip to content
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

Match Dblclick with Playwright's behavior #469

Closed
3 tasks done
ankur22 opened this issue Jul 27, 2022 · 3 comments
Closed
3 tasks done

Match Dblclick with Playwright's behavior #469

ankur22 opened this issue Jul 27, 2022 · 3 comments
Assignees
Labels
playwright Issue relating to Playwright compatibility

Comments

@ankur22
Copy link
Collaborator

ankur22 commented Jul 27, 2022

TODO:

xk6-browser docs imply that this dblclick issue is about locators, however, it's the behavior in our extension in general.


Tested against: dbede12

The method dblclick on locator 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.

import { sleep } from 'k6';
import { chromium } from 'k6/x/browser';

export default function () {
  const browser = chromium.launch({
    headless: false,
  });
  const context = browser.newContext();
  const page = context.newPage();
  const res = page.goto('https://test.k6.io/browser.php');
  const l = page.locator('#counter-button');
  sleep(1);
  l.dblclick();

  sleep(10);
  browser.close();
}

I was expecting the counter on this test page to go up to 2 but it only went up to 1. When testing with PW i was able to get the expected count of 2.

Tasks

@ankur22 ankur22 added the bug Something isn't working label Jul 27, 2022
@imiric
Copy link
Contributor

imiric commented Jul 27, 2022

Nice catch!

It doesn't seem related to Locator, but to ElementHandle:

func (h *ElementHandle) dblClick(p *Position, opts *MouseClickOptions) error {
return h.frame.page.Mouse.click(p.X, p.Y, opts)
}

It should call Mouse.dblClick() 😄

@inancgumus inancgumus self-assigned this Sep 12, 2022
@inancgumus inancgumus added this to the v0.6.0 milestone Sep 12, 2022
@inancgumus
Copy link
Member

inancgumus commented Sep 12, 2022

@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.

@ankur22
Copy link
Collaborator Author

ankur22 commented Sep 12, 2022

@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.

@inancgumus inancgumus changed the title The method dblclick on locator only clicks once The method dblclick only clicks once Sep 14, 2022
@inancgumus inancgumus changed the title The method dblclick only clicks once Match Dblclick match Playwright's behavior Oct 26, 2022
@inancgumus inancgumus changed the title Match Dblclick match Playwright's behavior Match Dblclick with Playwright's behavior Oct 26, 2022
@inancgumus inancgumus added the playwright Issue relating to Playwright compatibility label Oct 26, 2022
@inancgumus inancgumus removed this from the v0.6.0 milestone Nov 8, 2022
@inancgumus inancgumus removed their assignment Nov 8, 2022
@inancgumus inancgumus removed the bug Something isn't working label Feb 28, 2023
@ankur22 ankur22 self-assigned this Dec 1, 2023
@ankur22 ankur22 mentioned this issue Dec 5, 2023
3 tasks
@ankur22 ankur22 closed this as completed Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
playwright Issue relating to Playwright compatibility
Projects
None yet
Development

No branches or pull requests

3 participants