microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
65.8k stars 3.58k forks source link

[Bug]: enable viewport causes elements in page to disappear #29338

Closed xsoft7 closed 7 months ago

xsoft7 commented 7 months ago

Version

1.41.0

Steps to reproduce

update:

it seems that the issue happens strictly when The monitor resolution is >= viewport_size

to reproduce - if your resolution is 1920X1080, set the viewport size for example 2560X2000

you will see cut items and cannot manually scale down the browser window to see them

I found a quick overide- set viewport resolution to about 5% smaller that its is - so in my example, if my monitor is FHD - I set the viewport resolution to 1900X1000

conftest.py

@pytest.fixture(scope="session") def browser_context_args(browser_context_args, video_path): size = {"width": 1920, "height": 1080} return { browser_context_args, "record_video_dir": "./debug/videos/", "viewport": size,** 'record_video_size': size, }

@pytest.fixture def page(context: BrowserContext, base_url: str) -> Generator[Page, None, None]: page = context.new_page() page._goto = page.goto # type: ignore page.goto = lambda *args, **kwargs: _handle_page_goto( # type: ignore page, list(args), kwargs, base_url ) yield page

save off the test unique id

current_path_name = os.path.split(context.pages[0].video.path())[1]
context.current_video_name = current_path_name
page.close()

Expected behavior

to display content

Actual behavior

content is not displayed, the "save/cancel button"

Additional context

In a conftest.py as shown above, I have that custom fixture.

Thing is, when I enable the "viewport" in the dictionary, I lose some buttons.

When I remove "viewport", the buttons appear but the video recording is not full screen (per resolution I've set, there's like 1/4 of the screen.).

viewport enabled- no buttons, video recording is goodScreenshot 2024-02-04 at 10 43 21

viewport option is commented out - buttons are present, video recording is trimmed| Screenshot 2024-02-04 at 11 02 33

The video is not full screen/doesnt apply the set resolution (viewport is commented out)

Screenshot 2024-02-04 at 11 06 02

Environment

System:
    OS: macOS 14.3
    CPU: (10) arm64 Apple M1 Max
    Memory: 50.34 MB / 32.00 GB
  Binaries:
    Node: 16.18.1 - ~/.nvm/versions/node/v16.18.1/bin/node
    npm: 9.6.5 - ~/.nvm/versions/node/v16.18.1/bin/npm
  Languages:
    Bash: 3.2.57 - /bin/bash

python 3.12.1
xsoft7 commented 7 months ago

update:

it seems that the issue happens strictly when The monitor resolution is >= viewport_size

to reproduce - if your monitor resolution is 1920X1080, set the viewport size for example 2560X2000

you will see cut items and cannot manually scale down the browser window to see them

I found a quick override- set viewport resolution to about 5% smaller than it is - so in my example, if my monitor is FHD - I set the viewport resolution to 1900X1000

naseemx commented 7 months ago

Can u assign me this task

dgozman commented 7 months ago

@xsoft7 This seems to work as intended - when viewport does not fit your screen, you do not see some parts of the web page.

If you still believe this is a bug in Playwright, please follow the issue template and provide a self-contained repro that we can run locally. Unfortunately, I cannot run your code snippet - it does not even have imports.