Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问下这个框架要怎么使用unitypoco? #8

Open
stcnchenxin opened this issue Mar 18, 2022 · 0 comments
Open

请问下这个框架要怎么使用unitypoco? #8

stcnchenxin opened this issue Mar 18, 2022 · 0 comments

Comments

@stcnchenxin
Copy link

因为测试的应用是用unity的,所以把poco_driver 换成了 UnityPoco,但是跑的时候发现提示:OSError: socket connection broken。

看了下airtest的官方文档,说一般是因为需要启动应用之后才实例化UnityPoco。所以换成下面的方式,在 test_domo.app.setup_func 里启动应用之后再实例化UnityPoco,但是好像还是报这个错

# common.py
@allure.step('初始化驱动')
    def init_driver(self):
        # 创建设备驱动
        self.device_phone = my_retry_connect("android://{0}:{1}/{2}?cap_method=javacap&touch_method=adb".format(
            self.phone_ip, self.phone_port, self.phone_uuid))
        self.phone_dev = self.phone_uuid

    # init的时候抽离 poco的实例化,改为在启动应用后进行
    def init_poco_driver(self):
        addr = (self.phone_ip, self.phone_port)
        self.poco_phone_driver = UnityPoco(addr=addr, device=self.device_phone, poll_interval=1)
        # 关闭截图
        self.poco_phone_driver.screenshot_each_action = False

# test_demo.py
    @pytest.fixture(scope="function")
    def app(self, request, app_fixture, snapshot_writer):
        app_ins = app_fixture

        @allure.step
        def setup_func():
            snapshot_writer.add_worksheet(feature)
            app_ins.start_phone_app()
            sleep(6)
            app_ins.init_poco_driver()  # 启动应用后再实例化poco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant