Open Bug 1581494 Opened 5 years ago Updated 2 years ago

"WebDriver:TakeScreenshot" doesn't work on pages with absolutely positioned elements

Categories

(Remote Protocol :: Marionette, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: alexikam, Unassigned)

References

()

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36

Steps to reproduce:

I am trying to take a screenshot of full page using the https://github.com/deepsweet/foxr
However, I got an empty image.

Apparently the issue in not on the foxr side, since I also tried to implement screenshots using the marionette in the https://github.com/DevExpress/testcafe. An the result was the same.

There is no issue when I take a not full page screenshot.
Here is my markup:

<!DOCTYPE html>
<html>
    <head>
        <style>
            * {
                margin: 0;
                padding: 0;
            }
            body {
                background-color: black;
            }
            div.d {
                width: 50px;
                height: 50px;
                position: absolute;
            }
            .right {
                margin-left: 5000px;
            }
            .bottom {
                margin-top: 5000px;
            }
            .red {
                background-color: rgb(255, 0, 0);
            }
            .green {
                background-color: rgb(0, 255, 0);
            }
        </style>
    </head>
    <body>
        <div class="d left top red"></div>
        <div class="d right top green"></div>
        <div class="d left bottom green"></div>
        <div class="d right bottom red"></div>
    </body>
</html>
And here is foxr script:
```JS
const foxr = require('foxr').default;
(async () => {
    try {
        const browser = await foxr.connect();
        const page = await browser.newPage()
        await page.goto('http://127.0.0.1:8080/full-page.html');
        await page.screenshot({ path: 'example.png' })
        await browser.close()
    } catch (error) {
        console.error(error)
    }
})()



Actual results:

I got an empty image


Expected results:

Image should not be empty.

Hi @alexikam, for now I will set a component if isn't the right one please fell free to change it.
Regards,
Liviu

Component: Untriaged → Marionette
Product: Firefox → Testing

Basically similar to https://github.com/mozilla/geckodriver/issues/931 which already reported that a while ago, but we never filed a bug about it.

Currently we only take the documentElement's dimensions into account, which in the above case are close to zero, and as such the screenshot is empty. And that is what the WebDriver spec covers: https://w3c.github.io/webdriver/#take-screenshot

Do other drivers behave differently? For me it feels it would need an issue on https://github.com/w3c/webdriver/issues/ for discussion.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(alexikam)
Summary: Cannot make a full page screenshot of specific page using Marionette → "WebDriver:TakeScreenshot" doesn't work on pages with absolutely positioned elements

@Henrik
Thanks for your response.
Yes, this issue is similar.
To be honest I do not know on how other drivers behave. However, I understood your explanation, so ok.

Flags: needinfo?(alexikam)

Ok, so this is blocked on an agreement for https://github.com/w3c/webdriver/issues/1443.

Version: 69 Branch → Trunk

The priority flag is not set for this bug.
:automatedtester, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(dburns)
Flags: needinfo?(dburns)
Priority: -- → P3

Testing the above example with a non-fullscreen capture it is working fine since Firefox 70, which means it was fixed by my fix for bug 1559592. Only fullscreen is still broken, but will be fixed with bug 1571424, which will be available later today in Nightly.

It might be good to get two webdriver tests added for it once the dependencies have been fixed.

Depends on: 1559592, 1571424

Actually the behavior change might be inappropriate for non-fullscreen captures. We will have to wait for a conclusion on https://github.com/w3c/webdriver/issues/1443.

Severity: normal → S3
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.