#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
@File    :   conftest.py
@Time    :   2024/11/06 16:24:10
@Author  :   dulip3ng 
@Version :   1.0
@Desc    :   None
'''
import pytest
from playwright.sync_api import sync_playwright, expect, Page
from pages import nebula

expect.set_options(timeout=30_000)

@pytest.fixture(scope="module")
def browser():
    with sync_playwright() as p:
        # 启动有头浏览器
        browser = p.chromium.launch(headless=False, slow_mo=300)  # 设置headless=False来启用有头模式
        yield browser
        browser.close()

@pytest.fixture(scope="module")
def page(browser):
    # 为每个测试用例提供一个新的页面实例
    context = browser.new_context(viewport= {"width": 1920, "height": 1080})
    page = context.new_page()
    yield page
    page.close()
    context.close()

@pytest.fixture(scope="module")
def body_page(page):
    return nebula.new_body_page(page)

@pytest.fixture(scope="module")
def home_page(page):
    return nebula.new_home_page(page)

@pytest.fixture(scope="module")
def login_page(page):
    return nebula.new_login_page(page)

@pytest.fixture(scope="module")
def list_page(page):
    return nebula.new_list_page(page)

@pytest.fixture(scope="module")
def head_page(page):
    return nebula.new_head_page(page)

@pytest.fixture(scope="module")
def filter_page(page):
    return nebula.new_filter_page(page)
@pytest.fixture(scope="module")
def push_page(page):
    return nebula.new_push_page(page)