w3c / w3c/webdriver

Unable to take a screenshot of a fully loaded page

Open
#893 18 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
HTML
Stars
718
Forks
228
PR merge metrics
No merged PRs in 30d

Description

At the moment, with WebDriver, you can trivially wait until after the load event has fired before taking a screenshot. However, not everything delays the load event (see HTML's notion of "critical subresources" and "delays the load event"). Anything you can detect whether or not it has loaded using the DOM can equally be dealt with through the script APIs.

However, CSS is especially awkward because of https://github.com/w3c/csswg-drafts/issues/1088. At the moment, Edge doesn't block the load event on background-image and list-style-image and these are undetectable through the DOM.

We need some proper solution to this problem in a general sense. As a web developer, to do any sort of visual testing, you want to be able to take a screenshot of a page after everything has loaded (of course, this can get complicated by long polling XHR, WebSockets, etc.).

I think there's at least a couple of options options:

  • Convince everyone (WGs, implementers) that the page should be in a stable state after the load event has fired
  • Add some custom notion to WebDriver of loadedness (OperaDriver has something like this with opera.idle)

Notably, this is causing problems for wptrunner running reftests, as we need some way to take a screenshot after everything has loaded. (https://github.com/w3c/web-platform-tests/issues/5412)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the load-event discussion, HTML's critical-subresource behavior, and the CSS background-image and list-style-image cases described here. Compare the proposed WebDriver loadedness concept with OperaDriver's opera.idle and the wptrunner reftest need; done would require an agreed general solution for taking screenshots after the page reaches a stable state.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, html
Domain
testing, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.