Ejemplo n.º 1
0
def _login_edit_box(account, pwd):
    logger.info("login edit box...")
    logins = getter.get_login()
    logger.info("after get login...")
    if logins and len(logins) > 0:
        try:
            local_step = 10
            local_range = 20
            local_x = uiauto.info['displayWidth']
            user_edit = logins[0]
            info = user_edit.info
            local_y = (info['bounds']['top'] + info['bounds']['bottom']) / 2
            while None == re.search(account, user_edit.get_text(),
                                    re.IGNORECASE):
                # click the x point
                for i in range(0, local_range):
                    uiauto.wait.idle()
                    uiauto.click(local_x - i * local_step, local_y)
                    logger.info("click the usr x point. local_x is " +
                                str(local_x - i * local_step) +
                                ". local_y is " + str(local_y))
                uiauto.wait.idle()
                user_edit.set_text(account)
                uiauto.wait.update()
                # user
                logger.info("src and dest content.")
                logger.info(user_edit.get_text())
                logger.info(account)
            # pwd
            pwd_edit = logins[1]
            info = pwd_edit.info
            local_y = (info['bounds']['top'] + info['bounds']['bottom']) / 2
            for j in range(0, local_range):
                uiauto.click(local_x - j * local_step, local_y)
                logger.info("click the pwd x point. local_x is " +
                            str(local_x - j * local_step) + ". local_y is " +
                            str(local_y))
            uiauto.wait.idle()
            pwd_edit.set_text(pwd)
            logger.info("set pwd : " + pwd)
            # login
            uiauto.wait.idle()
            login_button = logins[2]
            login_button.click.wait()
            logger.info("login_button.click()")
            return 1
        except Exception as e:
            logger.info(e)
            stack = traceback.format_exc()
            logger.error(stack)
    else:
        logger.error("Can not get username/password elements")
        return -1
    return 0
Ejemplo n.º 2
0
def _login_edit_box(account, pwd):
    logins = getter.get_login()
    if logins and len(logins) > 0:
        try:
            local_step = 10
            local_range = 20
            local_x = uiauto.info['displayWidth']
            user_edit = logins[0]
            info = user_edit.info
            local_y = (info['bounds']['top'] + info['bounds']['bottom']) / 2
            while None == re.search(account, user_edit.get_text(), re.IGNORECASE):
                # click the x point
                for i in range(0, local_range):
                    uiauto.click(local_x - i * local_step, local_y)
                    logger.info(
                        "click the usr x point. local_x is " + str(local_x - i * local_step) + ". local_y is " + str(
                            local_y))
                uiauto.wait.idle()
                user_edit.set_text(account)
                uiauto.wait.update()
                # user
                logger.info("src and dest content.")
                logger.info(user_edit.get_text())
                logger.info(account)
            # pwd
            pwd_edit = logins[1]
            info = pwd_edit.info
            local_y = (info['bounds']['top'] + info['bounds']['bottom']) / 2
            for j in range(0, local_range):
                uiauto.click(local_x - j * local_step, local_y)
                logger.info(
                    "click the pwd x point. local_x is " + str(local_x - j * local_step) + ". local_y is " + str(
                        local_y))
            uiauto.wait.idle()
            pwd_edit.set_text(pwd)
            logger.info("set pwd : " + pwd)
            # login
            uiauto.wait.idle()
            login_button = logins[2]
            login_button.click.wait()
            logger.info("login_button.click()")
            return 1
        except Exception as e:
            logger.info(e)
            stack = traceback.format_exc()
            logger.error(stack)
    else:
        logger.error("Can not get username/password elements")
        return -1
    return 0
Ejemplo n.º 3
0
def _login_edit_box(account, pwd):
    logger.info("login edit box...")
    logins = getter.get_login()
    logger.info("after get login...")
    if logins and len(logins) > 0:
        try:
            local_step = 10
            local_range = 20
            local_x = uiauto.info['displayWidth']
            user_edit = logins[0]
            info = user_edit.info
            local_y = (info['bounds']['top'] + info['bounds']['bottom']) / 2
            user_edit.clear_text()
            user_tmp = user_edit.get_text()
            if len(
                    user_tmp
            ) > 0 and "QQ" not in user_tmp and u"用户名" not in user_tmp and u"手机号" not in user_tmp and "/" not in user_tmp:
                # click the x point
                for i in range(0, local_range):
                    package_name = get_current_pkgname()
                    if package_name != None and package_name != "com.tencent.mm" and package_name != "com.tencent.mobileqq":
                        logger.info(
                            "break login_edit_box because package not in tencent...  "
                            + package_name)
                        return
                    uiauto.click(local_x - i * local_step, local_y)
                    logger.info("click the usr x point. local_x is " +
                                str(local_x - i * local_step) +
                                ". local_y is " + str(local_y))
            #  uiauto.wait.idle()
            # user_edit.set_text(account)
            excute_adb_process("shell input text " + account)
            logger.info("accont:" + account)

            #   uiauto.wait.update()
            # logger.info("src and dest content.")
            # logger.info(user_edit.get_text())
            # pwd
            pwd_edit = logins[1]
            info = pwd_edit.info
            local_y = (info['bounds']['top'] + info['bounds']['bottom']) / 2
            for j in range(0, local_range):
                uiauto.click(local_x - j * local_step, local_y)
                logger.info("click the pwd x point. local_x is " +
                            str(local_x - j * local_step) + ". local_y is " +
                            str(local_y))
            uiauto.wait.idle()
            excute_adb_process("shell input text " + pwd)
            # pwd_edit.set_text(pwd)
            logger.info("set pwd : " + pwd)
            time.sleep(1)
            login_button = logins[2]
            login_button.click.wait()
            logger.info("login_button.click()")
            return 1
        except Exception as e:
            logger.info(e)
            stack = traceback.format_exc()
            logger.error(stack)
    else:
        logger.error("Can not get username/password elements")
        return -1
    return 0