-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[py] Use XWayland for internal Python Firefox tests #15601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cgoldberg
merged 12 commits into
SeleniumHQ:trunk
from
cgoldberg:py-xwayland-firefox-tests
Apr 10, 2025
+68
−0
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
94d242b
[py] Use XWayland for internal Python Firefox tests
cgoldberg 9820d83
[py] Also use XWayland for Firefox when running Remote
cgoldberg a622b07
Merge branch 'trunk' into py-xwayland-firefox-tests
cgoldberg cc99c98
[py] Fix quotes to make linter happy
cgoldberg 728121f
[py] Add tests
cgoldberg 2b3d57b
[py] Add headless support to tests
cgoldberg fbd8976
Merge branch 'trunk' into py-xwayland-firefox-tests
cgoldberg 72ff2e8
[py] Ignore linting error
cgoldberg 680e7f0
[py] Remove prints
cgoldberg 2bf59ea
Merge branch 'trunk' into py-xwayland-firefox-tests
cgoldberg 703ee4f
[py] Fix boolean
cgoldberg c50e4e0
Merge branch 'trunk' into py-xwayland-firefox-tests
cgoldberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
py/test/selenium/webdriver/firefox/firefox_sizing_tests.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Licensed to the Software Freedom Conservancy (SFC) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The SFC licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| import os | ||
| import platform | ||
| from unittest.mock import patch | ||
|
|
||
| import pytest | ||
|
|
||
| from selenium import webdriver | ||
| from selenium.webdriver.firefox.options import Options | ||
|
|
||
|
|
||
| def is_running_wayland(): | ||
| if platform.system() == "Linux" and os.getenv("WAYLAND_DISPLAY"): | ||
| return True | ||
| return False | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not is_running_wayland(), reason="This test only runs on Linux under Wayland") | ||
| def test_firefox_opens_large_when_running_xwayland(request): # noqa: F821 | ||
| options = Options() | ||
| if request.config.getoption("--headless"): | ||
| options.add_argument("-headless") | ||
| # setting environment variable `MOZ_ENABLE_WAYLAND=0` forces Firefox | ||
| # to run under XWayland on Wayland based systems | ||
| with patch.dict("os.environ", {"MOZ_ENABLE_WAYLAND": "0"}): | ||
| try: | ||
| driver = webdriver.Firefox(options=options) | ||
| size = driver.get_window_size() | ||
| assert size["height"] > 500 | ||
| assert size["width"] > 500 | ||
| finally: | ||
| driver.quit() | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not is_running_wayland(), reason="This test only runs on Linux under Wayland") | ||
| @pytest.mark.xfail(reason="https://bugzilla.mozilla.org/show_bug.cgi?id=1959040") | ||
| # Firefox opens in a small window when running on Linux/Wayland | ||
| def test_firefox_opens_large_when_running_wayland(request): # noqa: F821 | ||
| options = Options() | ||
| if request.config.getoption("--headless"): | ||
| options.add_argument("-headless") | ||
| try: | ||
| driver = webdriver.Firefox(options=options) | ||
| size = driver.get_window_size() | ||
| assert size["height"] > 500 | ||
| assert size["width"] > 500 | ||
| finally: | ||
| driver.quit() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.