|
| 1 | +import os |
| 2 | +from typing import Generator |
| 3 | + |
| 4 | +import pytest |
| 5 | +from dotenv import load_dotenv |
| 6 | +from playwright.sync_api import Playwright, sync_playwright |
| 7 | + |
| 8 | +from browserbase import Browserbase |
| 9 | + |
| 10 | +from .. import ( |
| 11 | + BROWSERBASE_API_KEY, |
| 12 | + playwright_basic, |
| 13 | + playwright_proxy, |
| 14 | + playwright_upload, |
| 15 | + playwright_captcha, |
| 16 | + playwright_contexts, |
| 17 | + playwright_downloads, |
| 18 | +) |
| 19 | + |
| 20 | +bb = Browserbase(api_key=BROWSERBASE_API_KEY) |
| 21 | +load_dotenv() |
| 22 | + |
| 23 | +CI = os.getenv("CI", "false").lower() == "true" |
| 24 | + |
| 25 | + |
| 26 | +@pytest.fixture(scope="session") |
| 27 | +def playwright() -> Generator[Playwright, None, None]: |
| 28 | + with sync_playwright() as p: |
| 29 | + yield p |
| 30 | + |
| 31 | + |
| 32 | +def test_playwright_basic(playwright: Playwright) -> None: |
| 33 | + playwright_basic.run(playwright) |
| 34 | + |
| 35 | + |
| 36 | +@pytest.mark.skipif(True, reason="Flaky and fails often") |
| 37 | +def test_playwright_captcha(playwright: Playwright) -> None: |
| 38 | + playwright_captcha.run(playwright) |
| 39 | + |
| 40 | + |
| 41 | +def test_playwright_contexts(playwright: Playwright) -> None: |
| 42 | + playwright_contexts.run(playwright) |
| 43 | + |
| 44 | + |
| 45 | +def test_playwright_downloads(playwright: Playwright) -> None: |
| 46 | + playwright_downloads.run(playwright) |
| 47 | + |
| 48 | + |
| 49 | +def test_playwright_proxy_enable_via_create_session(playwright: Playwright) -> None: |
| 50 | + playwright_proxy.run_enable_via_create_session(playwright) |
| 51 | + |
| 52 | + |
| 53 | +def test_playwright_proxy_enable_via_querystring(playwright: Playwright) -> None: |
| 54 | + playwright_proxy.run_enable_via_querystring_with_created_session(playwright) |
| 55 | + |
| 56 | + |
| 57 | +@pytest.mark.skipif(CI, reason="Flaky and fails on CI") |
| 58 | +def test_playwright_proxy_geolocation_country(playwright: Playwright) -> None: |
| 59 | + playwright_proxy.run_geolocation_country(playwright) |
| 60 | + |
| 61 | + |
| 62 | +@pytest.mark.skipif(CI, reason="Flaky and fails on CI") |
| 63 | +def test_playwright_proxy_geolocation_state(playwright: Playwright) -> None: |
| 64 | + playwright_proxy.run_geolocation_state(playwright) |
| 65 | + |
| 66 | + |
| 67 | +@pytest.mark.skipif(CI, reason="Flaky and fails on CI") |
| 68 | +def test_playwright_proxy_geolocation_american_city(playwright: Playwright) -> None: |
| 69 | + playwright_proxy.run_geolocation_american_city(playwright) |
| 70 | + |
| 71 | + |
| 72 | +@pytest.mark.skipif(CI, reason="Flaky and fails on CI") |
| 73 | +def test_playwright_proxy_geolocation_non_american_city(playwright: Playwright) -> None: |
| 74 | + playwright_proxy.run_geolocation_non_american_city(playwright) |
| 75 | + |
| 76 | + |
| 77 | +def test_playwright_upload(playwright: Playwright) -> None: |
| 78 | + playwright_upload.run(playwright) |
0 commit comments