0

I am trying to simulate a mousedown action on an element then take a snapshot but this doesn't seem to work as the screenshot isn't what I expect.

according to the api docs, this is what it does

mouse.down([options])
options <Object>
button <"left"|"right"|"middle"> Defaults to left.
clickCount <number> defaults to 1. See UIEvent.detail.
returns: <Promise>
Dispatches a mousedown event.

I have tried the following:

  it('primary button visually looks correct on mouse down', async () => {
    await page.goto('my_url_page');
    await page.waitForSelector(testData.button, 20000);
    const elementHandle = await page.$(testData.button);
    await page.mouse.move(0, 0);
    await page.mouse.down();
    const image = await elementHandle.screenshot();

    expect(image).toMatchImageSnapshot();
  });

the button has some animation when the mouse is pressed down and this is what I want to take a screenshot of.

Appreciate the support with this

  • 1
    You are moving the mouse to the position `(0, 0)`. Is the element actually at that position? Also, it would be easier to help you if you could provide one of the images. – Thomas Dondorf May 03 '19 at 14:43
  • hi, yes the image is exactly at that position..`````` – user2240134 May 04 '19 at 16:37
  • And is the clickable part of the button also in that position? The button could have a rounded corner, a `margin` or something similar making the corner of the button not clickable. – Thomas Dondorf May 04 '19 at 16:51
  • Hi again, just to confirm, the click works fine. It’s the mouse down action I’m struggling with. How to call mouse down on an element i.e the button. – user2240134 May 05 '19 at 12:02

0 Answers0