Skip to content

[BUG] Element loses hover when calling locator.screenshot and playwright is run in headed mode in Docker #12077

Closed as not planned

Description

Context:

  • Playwright Version: 1.18.1
  • Operating System: Mac
  • Node.js version: 17.4.0
  • Browser: Chromium
  • Extra: The command i'm running in the Docker container (from mcr.microsoft.com/playwright:v1.18.1-focal) is:
xvfb-run playwright test --config=src/id-cta-ci.config.ts

id-cta-ci.config.ts:

import { PlaywrightTestConfig } from '@playwright/test';
import os from 'os';

const config: PlaywrightTestConfig = {
  forbidOnly: false,
  grep: /@id-cta/,
  reporter: [['list'], ['allure-playwright']],
  retries: 1,
  use: {
    headless: false,
    launchOptions: {
      args: ['--disable-dev-shm-usage']
    },
    screenshot: 'only-on-failure',
    trace: 'off',
    video: 'off'
  },
  workers: os.cpus().length
};

export default config;

System:

  • OS: macOS 12.0.1
  • Memory: 24.32 MB / 16.00 GB

Binaries:

  • Node: 17.4.0 - /usr/local/bin/node
  • Yarn: 1.22.17 - /usr/local/bin/yarn
  • npm: 8.3.1 - /usr/local/bin/npm

Languages:

  • Bash: 3.2.57 - /bin/bash

npmPackages:

  • playwright-chromium: 1.18.1 => 1.18.1

Code Snippet

 test.only('sample test', async ({ page }) => {
    await page.goto('https://account.test.bbc.com/account/tv');
    const signIn = page.locator('a:has-text("Sign in")');
    const pageWrapper = page.locator('div.page__content');
    await signIn.hover();
    await page.waitForTimeout(250);
    await pageWrapper.screenshot({ path: 'screenshot.png' });
  });

Describe the bug

The sign in link loses hover when pageWrapper.screenshot is called.

screenshot.png is:

screenshot

If you set headless: true in the config file and re-run the test the screenshot is:

screenshot

If you run playwright on the host (not in a Docker container), this works okay in headless and headed modes.

Interestingly, when I replaced pageWrapper.screenshot with page.screenshot, the link had hover in the screenshot.

Activity

  1. SpiderZZZ commented on Apr 11, 2022

    @SpiderZZZ

    have same problem

  2. tian-jeff commented on Apr 15, 2022

    @tian-jeff

    same problem

  3. RAFraz commented on Oct 5, 2022

    @RAFraz

    Still having this problem.

  4. rrios-dev commented on Apr 9, 2023

    @rrios-dev

    any update on this problem?

  5. pbn04001 commented on Jun 12, 2023

    @pbn04001

    Still a problem, any updates?

  6. maxime1992 commented on Jun 13, 2023

    @maxime1992

    Guys, looking at the last 6 comments do you feel like you'll add more weight to this issue by asking this?

    There's only me and "hsn-nxt" who upvoted the issue. He's not commented and neither had I so far. Meaning that none of the "any update" comment has even upvoted the issue.

    I'll assume you're not really aware and explain how to show support to an issue without being noisy:

    First, put a thumbs up on the issue:

    image

    Done.

    The maintainer can then in the issue view filter by most upvotes to see what they should prioritize instead of counting noisy comments.

    image

    If you look at this view, do you feel like "any updates" helps or that you'd be better off putting a 👍?

    Thanks.

    EDIT: Re-reading this a few hours later, I do sound a bit rude. Apologies for the abrupt message.

  7. pavelfeldman commented on Oct 31, 2026

    @pavelfeldman
    Member

    We're closing all P3-collecting-feedback issues and retiring the label. #43813 explains why. This doesn't mean the request is wrong. If it still matters to you, please open a new issue against the latest Playwright version with your concrete use case and link back here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions