diff --git a/tests/conftest.py b/tests/conftest.py index 0c3f7b3e0..6b3a801f8 100755 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -74,7 +74,7 @@ def glances_webserver(): @pytest.fixture(scope="session") -def firefox_browser(): +def web_browser(): """Init Firefox browser.""" opt = ChromeOptions() opt.add_argument("--headless") diff --git a/tests/test_webui.py b/tests/test_webui.py index 60c45a772..09f324c38 100755 --- a/tests/test_webui.py +++ b/tests/test_webui.py @@ -11,16 +11,49 @@ import os import tempfile +import time import pytest from selenium.webdriver.common.by import By +SCREENSHOT_RESOLUTIONS = [ + # PC + (640, 480), + (800, 600), + (1024, 768), + (1600, 900), + (1280, 1024), + (1600, 1200), + (1920, 1200), + # IPHONE + (750, 1334), # 8 + (1080, 1920), # 8 Plus + (1242, 2208), # XS + (1125, 2436), # 11 Pro + (1179, 2556), # 15 + (1320, 2868), # 16 Pro Max + # PIXEL Phone + (1080, 2400), # Pixel 7 +] + @pytest.fixture(scope="module") -def glances_homepage(firefox_browser): - firefox_browser.get("http://localhost:61234") - firefox_browser.save_screenshot(os.path.join(tempfile.gettempdir(), "glances.png")) - return firefox_browser +def glances_homepage(web_browser): + time.sleep(3) + web_browser.get("http://localhost:61234") + return web_browser + + +def test_screenshot(glances_webserver, glances_homepage): + """ + Test Glances home page screenshot. + """ + glances_webserver is not None + for resolution in SCREENSHOT_RESOLUTIONS: + glances_homepage.set_window_size(*resolution) + glances_homepage.save_screenshot( + os.path.join(tempfile.gettempdir(), f"glances-{'-'.join(map(str, list(resolution)))}.png") + ) def test_loading_time(glances_webserver, glances_homepage):