diff --git a/tests/assets/client.py b/tests/assets/client.py index 5129ed2dc..670242f5d 100644 --- a/tests/assets/client.py +++ b/tests/assets/client.py @@ -12,22 +12,23 @@ # See the License for the specific language governing permissions and # limitations under the License. +import sys from pathlib import Path from playwright.sync_api import Playwright, sync_playwright -def main(playwright: Playwright) -> None: - for browser_type in [playwright.chromium, playwright.firefox, playwright.webkit]: - browser = browser_type.launch() - page = browser.new_page() - page.goto("data:text/html,Foobar") - here = Path(__file__).parent.resolve() - page.screenshot(path=here / f"{browser_type.name}.png") - page.close() - browser.close() +def main(playwright: Playwright, browser_name: str) -> None: + browser = playwright[browser_name].launch() + page = browser.new_page() + page.goto("data:text/html,Foobar") + here = Path(__file__).parent.resolve() + page.screenshot(path=here / f"{browser_name}.png") + page.close() + browser.close() if __name__ == "__main__": + browser_name = sys.argv[1] with sync_playwright() as p: - main(p) + main(p, browser_name) diff --git a/tests/test_installation.py b/tests/test_installation.py index fa319f5e3..ccde56361 100644 --- a/tests/test_installation.py +++ b/tests/test_installation.py @@ -20,7 +20,7 @@ from venv import EnvBuilder -def test_install(tmp_path: Path) -> None: +def test_install(tmp_path: Path, browser_name: str) -> None: env = EnvBuilder(with_pip=True) env.create(env_dir=tmp_path) context = env.ensure_directories(tmp_path) @@ -43,10 +43,10 @@ def test_install(tmp_path: Path) -> None: environ = os.environ.copy() environ["PLAYWRIGHT_BROWSERS_PATH"] = str(tmp_path) subprocess.check_output( - [context.env_exe, "-m", "playwright", "install"], env=environ + [context.env_exe, "-m", "playwright", "install", browser_name], env=environ ) shutil.copyfile(root / "tests" / "assets" / "client.py", tmp_path / "main.py") - subprocess.check_output([context.env_exe, str(tmp_path / "main.py")], env=environ) - assert (tmp_path / "chromium.png").exists() - assert (tmp_path / "firefox.png").exists() - assert (tmp_path / "webkit.png").exists() + subprocess.check_output( + [context.env_exe, str(tmp_path / "main.py"), browser_name], env=environ + ) + assert (tmp_path / f"{browser_name}.png").exists()