Appium驱动程序未初始化

时间:2020-05-05 06:47:27

标签: python android appium pytest

在运行我的代码时,在 driver = webdriver.Remote(“ http://127.0.0.1:4723/wd/hub”,required_cap)处陷入僵局,然后什么也没有发生,没有错误,没有警告,代码没有前言。 Appium版本:v1.17.0 操作系统:赢10 here中有一个类似的问题,但是它在Java中,因此我无法在python中找到任何解决方案。 参考代码:

import logging
from appium.webdriver.appium_service import AppiumService
from appium import webdriver


logger = logging.getLogger('framework')

FATEL_APPIUM_SERVER_ERROR = "fatal appium error while python tries to communicate with appium over HTTP." \
                            "could be caused by resources constraints or due to failure of Python appium client" \
                            "library."


class Mobile_adapter:

    def __init__(self):
        self._appium_Service = AppiumService()
        self.active_Server = None

    def start_Server(self):
        """initiates appium server and returns it's status as true or false"""
        max_retries = 0
        self.active_Server = self._appium_Service.start()
        while self._appium_Service.is_running is False and max_retries != 3:
            self._appium_Service.start(args=['--address', '0.0.0.1', '-p', str(4723)])
            max_retries += 1
            if max_retries == 3:
                raise Exception(FATEL_APPIUM_SERVER_ERROR)
        logger.info('Appium server up and running')

    def kill_server(self):
        # self.active_Server.stop()
        self._appium_Service.stop()
        status = self._appium_Service.is_running
        return status


if __name__ == "__main__":
    m = Mobile_adapter()
    m.start_Server()
    path = "C:\\application.apk"
    desired_cap = {"platformName": "Android", "deviceName": "emulator-5554",
                   "app": path, "noReset": "True",
                   "appWaitActivity": "LoginActivity", "appWaitPackage": "appPackage"}

    driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_cap)
    import time
    time.sleep(10)

当我从cmd手动启动appium服务器时,代码工作正常,但是当尝试通过AppiumService进行操作时,卡住了driver = webdriver.Remote()的处理,没有任何错误或警告,并且设备上没有任何反应。

服务器日志

2020-05-06 06:06:14:957 [Appium] Welcome to Appium v1.17.0
2020-05-06 06:06:14:958 [Appium] Non-default server args:
2020-05-06 06:06:14:958 [Appium] logFile: C:/Users/vsingh/AppData/Roaming/Appium/logs/appium.log
2020-05-06 06:06:14:959 [Appium] logTimestamp: true
2020-05-06 06:06:14:990 [Appium] Appium REST http interface listener started on 0.0.0.0:4723
2020-05-06 06:06:15:477 [HTTP] --> HEAD /wd/hub/status
2020-05-06 06:06:15:477 [HTTP] {}
2020-05-06 06:06:15:481 [GENERIC] Calling AppiumDriver.getStatus() with args: []
2020-05-06 06:06:15:483 [GENERIC] Responding to client with driver.getStatus() result: {"build":{"version":"1.17.0"}}
2020-05-06 06:06:15:489 [HTTP] <-- HEAD /wd/hub/status 200 10 ms - 68
2020-05-06 06:06:15:489 [HTTP]
2020-05-06 06:06:17:553 [HTTP] --> POST /wd/hub/session

After **POST /wd/hub/session** nothing happen and program didn't throw any error and goes in deadlock.

0 个答案:

没有答案