Skip to content

[BUG] chromium and webkit screenshot ignoring screenshot: clip: height option property #1030

@aesyondu

Description

@aesyondu

Context:

  • Playwright Version: 0.11.1
  • Operating System: Mac OS X 10.14.6
  • Extra: node@11.15.0 npm@6.7.0

Code Snippet
Full repo:
https://github.com/aesyondu/javascript-questions/tree/tmp/playwright-sample

Specific commit:
aesyondu/javascript-questions@4d9b189

index.js

const path = require("path")
const { firefox } = require("playwright-firefox");
const { chromium } = require("playwright-chromium");
const { webkit } = require("playwright-webkit");

(async () => {
    const browser = await firefox.launch({ headless: false })
    // const browser = await chromium.launch({ headless: false })
    // const browser = await webkit.launch({ headless: false })
    const context = await browser.newContext()
    context.setDefaultTimeout(9999999)
    const page = await context.newPage()

    await page.goto(`file:${path.join(__dirname, "index.html")}`) // 2. firefox not resolving page.goto file:
    console.log("FIREFOX not outputting this")

    const question = await page.$("h6[id^='1']")
    const {x: xStart, y: yStart, width: widthStart} = await question.boundingBox()

    const limit = await page.$("h6[id^='2']")
    const {x: xEnd, y: yEnd} = await limit.boundingBox()

    const heightCalc = yEnd - yStart
    const heightCalc2 = (yEnd - yStart) * 2
    console.log(yStart, yEnd, heightCalc)
    await page.screenshot({
        clip: {
            x: xStart,
            y: yStart,
            width: widthStart,
            height: 1000, // 2. chromium and webkit not using the height here
        },
        // path: "./chromium.png",
        path: "./webkit.png",
    })
    console.log("FINISH")
    await browser.close()
})()

Describe the bug
Using screenshot: clip: height, the height is ignored, and is capped at 177px. However, if I change it to height: 10, it becomes 10px.

Couldn't test with firefox due to the page.goto: file bug. It's already reported.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions