Beispiel #1
0
def login_tencent(account, pwd, timeout=180):
    start_time = time.time()
    end_time = start_time
    logger.info("login tencent...")

    while end_time - start_time < timeout:
        # 在密码框界面之前可能会有另一个跳转界面需要处理
        package_name = uiauto.info["currentPackageName"]
        if package_name is None:
            if os.environ.get("UIAUTOMATORPORT") is None:
                logger.info("uiautomator dump failed...restart uiautomator")
                m.init_uiautomator()
            else:
                logger.info(
                    "uiautomator dump failed...sleep to wait platform reconnecting"
                )
                time.sleep(5)  #m.restartPlatformDialogHandler()
            package_name = uiauto.info["currentPackageName"]
        if package_name == "com.tencent.mobileqq":
            _prelogin_qq()
        elif package_name == "com.tencent.mm":
            _prelogin_wechat()
        _login_edit_box(account, pwd)
        if package_name == "com.tencent.mobileqq":
            _login_qq()
            _afterlogin()
        elif package_name == "com.tencent.mm":
            _login_wx()
        elif package_name is not None and time.time() - start_time > 15:
            logger.info("login success. package: " + package_name)
            return True
        else:
            logger.info("get current pkg failed")
        end_time = time.time()
    return False
Beispiel #2
0
 def reconnectUiautomator():
     if os.environ.get("UIAUTOMATORPORT") is None:
         logger.info(
             "uiautomator get currentPackageName failed...restart uiautomator"
         )
         m.init_uiautomator()
     else:
         logger.info(
             "uiautomator get currentPackageName failed...sleep to wait platform reconnecting"
         )
         time.sleep(10)  # m.restartPlatformDialogHandler()