Skip to content

放入pytest框架中执行,好像前置和用例通信出现问题 #3

Description

@ftdreams
import pytest
from playwright.async_api import async_playwright
from pymidscene import PlaywrightAgent

from config.common import VL_MODEL
from libraries.common.CommonClass import project_path, ce


class TestDeleteData:
    @pytest.fixture(scope='class', autouse=True)
    async def user_setup_class(self):
        html_path = project_path / "login_demo.html"
        ce.html_url = f"file:///{html_path.as_posix()}"
        ce.p = await async_playwright().start()
        browser = await ce.p.chromium.launch(headless=False, channel='chrome')
        context = await browser.new_context(ignore_https_errors=True, bypass_csp=True)
        ce.page = await context.new_page()
        report_dir = project_path / 'report'
        ce.agent = PlaywrightAgent(ce.page, report_dir=report_dir, model_config=VL_MODEL, cache_id="report")
        await ce.page.goto(ce.html_url)

        yield
        ce.agent.finish()
        await browser.close()
        await ce.p.stop()

    async def test_0001(self):
        """测试1: 输入用户名和密码"""
        await ce.agent.ai_input("用户名输入框", "admin")

    # async def test_0002(self):
    #     """测试2"""
    #     await ce.agent.ai_input("密码输入框", "123456")

我想将浏览器初始化、登录等操作放在前置内,但发现ai_input输入操作可以在fixture中执行,但在用例内
playwright_impl_page.py会卡在这个库的

 encoded_binary = await self._channel.send(
            "screenshot", self._timeout_settings.timeout, params
        )

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions