Update.
This commit is contained in:
+31
-2
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
import asyncio
|
||||
from playwright.async_api import async_playwright
|
||||
from playwright.async_api import async_playwright, Page, expect
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def event_loop():
|
||||
@@ -35,4 +35,33 @@ async def page(context):
|
||||
|
||||
@pytest.fixture
|
||||
def base_url():
|
||||
return "http://localhost:8000"
|
||||
return "http://localhost:9004"
|
||||
|
||||
@pytest_asyncio.fixture(scope="function", autouse=True)
|
||||
async def login(page: Page, base_url):
|
||||
print(f"Navigating to base_url: {base_url}")
|
||||
await page.goto(f"{base_url}/")
|
||||
await page.screenshot(path="01_initial_page.png")
|
||||
|
||||
# If already logged in, log out first to ensure a clean state
|
||||
if await page.locator('a:has-text("Logout")').is_visible():
|
||||
await page.click('a:has-text("Logout")')
|
||||
await page.screenshot(path="02_after_logout.png")
|
||||
|
||||
# Now, proceed with login or registration
|
||||
login_form = page.locator('#login-form:visible')
|
||||
if await login_form.count() > 0:
|
||||
await login_form.locator('input[name="username"]').fill('billingtest')
|
||||
await login_form.locator('input[name="password"]').fill('password123')
|
||||
await page.screenshot(path="03_before_login_click.png")
|
||||
await expect(page.locator('h2:has-text("Files")')).to_be_visible(timeout=10000)
|
||||
else:
|
||||
# If no login form, try to register
|
||||
await page.click('text=Sign Up')
|
||||
register_form = page.locator('#register-form:visible')
|
||||
await register_form.locator('input[name="username"]').fill('billingtest')
|
||||
await register_form.locator('input[name="email"]').fill('billingtest@example.com')
|
||||
await register_form.locator('input[name="password"]').fill('password123')
|
||||
await page.screenshot(path="05_before_register_click.png")
|
||||
await register_form.locator('button[type="submit"]').click()
|
||||
await expect(page.locator('h1:has-text("My Files")')).to_be_visible(timeout=10000)
|
||||
Reference in New Issue
Block a user