← Back to Discord Forum

Had clip option been removed from the .havescreenshot() method?

bronzebearduaposted in #help-playwright
Open in Discord

As per title: I recently started to wright test and in one of the I need to check if the 2 images match. I decided to go with havescreenshot() method to achieve. I need to cut the original snapshot a bit and checked the Wiki for optins and found ** clip option** https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1-option-clip I tried to use clip option to set both of them to same size but that option does not exist in the code base. Had it been removed?

This thread is trying to answer question "Has the 'clip' option been removed from the .havescreenshot() method in Playwright?"

4 replies

"but that option does not exist in the code base." What do you mean? Are you getting an error?


It's there for me in Playwright 1.38:


await expect(page).toHaveScreenshot('test.png', { clip: { x: 10, y: 10, width: 100, height: 100 } });


Just found a bug on Github for this: https://github.com/microsoft/playwright/issues/27426 Raised by you? You can (currently) only use clip with a page, not a locator

Related Discord Threads

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.