Beispiel #1
0
    def start_poco(self, debug=False):
        """
		调试时不需要登录又需要重新实例poco时可单独调用使用
		"""
        if not debug:
            time.sleep(15)
        init_poco = StdPoco()
        init_poco.use_render_resolution()
        return init_poco
 def testcase02(self):
     u'''示例case2'''
     login('changeaccount')
     poco = StdPoco()
     sleep(3.0)
     poco = StdPoco()
     touch(
         Template(r"tpl1559804215578.png",
                  record_pos=(-0.227, 0.07),
                  resolution=(1280, 720)))  #
     sleep(60.0)
Beispiel #3
0
 def test_kfonline(self):
     '跳转到在线客服测试'
     poco = StdPoco()
     poco("Layout")[1].offspring("btn_kefu").click()
     from poco.drivers.android.uiautomation import AndroidUiautomationPoco
     poco = AndroidUiautomationPoco(use_airtest_input=True,
                                    screenshot_each_action=False)
     if poco(
             "com.dashengzhangyou.pykf.lailaiguangdong:id/message_fragment_container"
     ).offspring(
             "com.dashengzhangyou.pykf.lailaiguangdong:id/messageListView"
     ).child("android.widget.RelativeLayout")[0].offspring(
             "com.dashengzhangyou.pykf.lailaiguangdong:id/message_item_content"
     ).offspring(
             "com.dashengzhangyou.pykf.lailaiguangdong:id/clickable_item_text"
     ):
         self.rgkf = poco(
             "com.dashengzhangyou.pykf.lailaiguangdong:id/message_fragment_container"
         ).offspring(
             "com.dashengzhangyou.pykf.lailaiguangdong:id/messageListView"
         ).child("android.widget.RelativeLayout")[0].offspring(
             "com.dashengzhangyou.pykf.lailaiguangdong:id/message_item_content"
         ).offspring(
             "com.dashengzhangyou.pykf.lailaiguangdong:id/clickable_item_text"
         )
         if self.rgkf.get_text() == '人工客服':
             print('客服系统跳转--测试通过')
             keyevent("BACK")
     else:
         print('客服系统跳转异常--测试失败')
         assert (self.rgkf.get_text() == '人工客服')
Beispiel #4
0
 def test_getklq(self):
     '可领取界面跳转测试'
     poco = StdPoco()
     poco("btn_pan2").child("Image_unselect").child("lab_pan1").click()
     assert (poco("lab_bg1").get_text() == '当前可领取:')
     print('可领取界面显示正常--测试通过')
     poco("Image_26").click()
Beispiel #5
0
 def send_game_protocol(self, send_protocol_dic,find_name):# todo
     """
     使用协议对游戏进行操作,例如穿戴装备,强化装备等
     发送后会回到当前界面,只发一条
     :param add_name_input_list: list [协议id,arges....]
     :param find_name:协议返回值中需要查询值的key,可以为none
     :return:value
     """
     self.poco = StdPoco()
     self.my_poco.set_poco(self.poco)
     self.my_poco.find_poco("Comp_res3", find_type="name")  # 点击元宝进入gm
     self.my_poco.find_poco("自动测试")
     self.my_poco.find_poco("input2", find_type="name")
     protocol_str = str(send_protocol_dic).replace(" ","").replace("'",'''"''') # 要发送的协议
     self.info.text_str(protocol_str)
     s = self.poco("Comp_scroll").get_text()  # 获取到的返回值
     s = s[6:]
     s1 = re.sub('(\w+) = ([^\{ ]+)', "\"\\1\":\\2,", s)
     s1 = s1.replace("false", "False")
     s1 = s1.replace("ture", "Ture")
     s2 = re.sub("\s{2,}", "", s1)
     s3 = re.sub("(\w+) = {", "\"\\1\" : {", s2)
     s4 = re.sub("}", "},", s3)
     s = s4[0:-1]
     ret_dic = eval(s) # todo
     self.my_poco.find_poco("btn2", find_type="name")
     self.my_poco.find_poco("close", find_type="name")
     self.my_poco.find_poco("close1", find_type="name")  # 回到主界面
     if find_name != None:
         find_name_value = None #todo
         return find_name_value
Beispiel #6
0
def in_backend():
    #实例化一次poco,一用全局初始化就报10053错,很是头疼
    poco = StdPoco()
    poco("loginBtn").click()
    sleep(20)
#调用拍脸处理函数
    popup()
Beispiel #7
0
    def get_resource_num_ss2(self, get_name_input_list):
        """
        从开始到结束都在当前界面,查询身上的资源数量
        :return:返回字典,道具的名称和数量
        """
        self.poco = StdPoco()
        self.my_poco.set_poco(self.poco)
        mes = MessageSs2()
        s = "["
        for key_num in range(len(get_name_input_list)):
            s = s + "{" + mes.get_resource_value(get_name_input_list[key_num]) + "}"
            if key_num == len(get_name_input_list) - 1:
                pass
            else:
                s = s + ","
        s = s + "]"
        self.my_poco.find_poco("Comp_res3", find_type="name")
        self.my_poco.find_poco("自动测试")
        self.my_poco.find_poco("input2", find_type="name")
        self.info.text_str(s)
        self.my_poco.find_poco("btn2", find_type="name")
        str_txt = self.poco("txt").get_text()
        number_list = str_txt.split(",")  # 将获取到的字符串解析成列表
        resource_dic = {}
        for i in range(len(number_list)):
            key_name = get_name_input_list[i]
            value_name = int(number_list[i])
            resource_dic.update({key_name: value_name})

        self.my_poco.find_poco("close", find_type="name")
        self.my_poco.find_poco("close1", find_type="name")
        return resource_dic
Beispiel #8
0
 def delete_resource_ss2(self, del_name_input_dic):
     """
     从开始到结束都在当前界面,删除一些资源
     :return:
     """
     self.poco = StdPoco()
     self.my_poco.set_poco(self.poco)
     mes = MessageSs2()
     # 将传入的字典的key转换成列表
     keys_list = list(del_name_input_dic.keys())
     order_str = """{"message":10140,"consumes":["""
     counter_num = 0
     for key in keys_list:
         if counter_num == 0:
             pass
         else:
             order_str = order_str + ","
         size = del_name_input_dic.get(key)
         value = mes.get_resource_value(key)
         order_str = order_str + "{" + value + ""","size":""" + str(size) + "}"
         counter_num += 1
     order_str = order_str + "]}"
     order_str.replace(" ", "")
     self.my_poco.find_poco("Comp_res3", find_type="name")  # 点击元宝进入gm
     self.my_poco.find_poco("自动测试")
     self.my_poco.find_poco("input1", find_type="name")
     self.info.text_str(order_str)
     self.my_poco.find_poco("btn1", find_type="name")
     self.my_poco.find_poco("close", find_type="name")
     self.my_poco.find_poco("close1", find_type="name")  # 回到主界面
Beispiel #9
0
 def HandleInterfacaBox(self):
     '''
     处理初次进入界面可能弹出的活动弹窗
     :return:
     '''
     from poco.drivers.android.uiautomation import AndroidUiautomationPoco
     poco = AndroidUiautomationPoco(use_airtest_input=True,
                                    screenshot_each_action=False)
     try:
         tips_realname = poco(package + ":id/bt_dialog_close")  # 弹框的关闭按钮
         if tips_realname:
             tips_realname.click()
     except:
         pass
     sleep(2)
     poco = StdPoco()
     try:
         tips_change_name = poco("JJButtondialog_close_btn_n")
         # 弹框的关闭按钮
         biaoshi = poco("SceneBaseRootView").child("JJViewGroup")[0].\
             child("JJImagepage_indicator_common")[1]
         # 大厅下方的页标识
         if tips_change_name:
             biaoshi.click()
     except:
         pass
     sleep(2)
 def setUp(self):
     auto_setup(__file__)  # 初始化Airtest所需的一些连接
     poco = StdPoco()
     PublicMethod().InstallAPK()  # 未安装测试apk时,安装测试apk
     start_app(package)  # 启动APK
     PublicMethod().HandleAuthority()  # 处理启动APP时的权限弹框
     sleep(7.0)
Beispiel #11
0
def other_login():
    odev = ChangeDev()
    o = odev.changedev()
    set_current(1)
    start_app('com.dashengzhangyou.pykf.lailaiguangdong')
    time.sleep(5)
    poco = StdPoco()
    poco("<Node | Tag = -1").child("Button")[1].click()  #点击进入openid界面
    poco("<Node | Tag = -1").child("<LayerColor | Tag = -1>")[1].child(
        "Widget")[1].click()  #点击openid输入框,方便输入openid
    text(id)  #随机输入5位id
    poco("<Node | Tag = -1").child("<LayerColor | Tag = -1>")[1].child(
        "Button").click()  #点击下方按钮
    time.sleep(3)
    poco("Layout")[1].offspring("city_list").child("root")[0].offspring(
        "btn_1").click()  #选择城市
    poco("Layout")[1].offspring("btn_yes_city").click()  #点击“确定”
    poco("yes").click()  #确认选择城市
    time.sleep(5)
    yzm = poco("lab_regist_verify")
    if yzm.exists():
        poco("closeBtn").click()
    else:
        print('not found')
    poco("btn_new").click()
    poco("btn_select2").child("label_name").click()
    poco("btn_sure").click()
    assert poco("cancleBtn").get_text() == "解散房间"
    roomNumbers = (poco("roomNum").get_text())
    return roomNumbers
Beispiel #12
0
 def test_jiesanqyroom(self):
     u'解散亲友房'
     poco=StdPoco()
     poco("cancleBtn").click()
     poco("btn_yes").click()
     assert(poco("Label_39").get_text()=='管理亲友圈房间模版')
     print('解散亲友房--测试通过')
Beispiel #13
0
 def test_creatrooms(self):
     u'创建房间'
     getdev = ChangeDev()
     getdev.changedev()
     set_current(0)
     poco = StdPoco()
     if poco("img_yuanbao").exists():
         poco("closeBtn").click()
         if poco("btn_new").exists():
             poco("btn_new").click()
             if poco("pan_newer_ddz").exists():
                 poco("Layout")[6].offspring("Image_bg").click()
                 poco("Layout")[6].offspring("list_view_select").offspring(
                     "btn_select1").click()
                 poco("Layout")[7].offspring("btn_sure").click()
                 assert (poco("cancleBtn").get_text() == "解散房间")
                 print('测试通过')
             else:
                 poco("btn_select2").child("label_name").click()
                 poco("btn_sure").click()
                 assert (poco("cancleBtn").get_text() == "解散房间")
                 print('测试通过')
         else:
             assert_equal(1, 2, msg='没找元素,测试失败')
     else:
         if poco("btn_new").exists():
             poco("btn_new").click()
             poco("btn_select2").child("label_name").click()
             poco("btn_sure").click()
             assert (poco("cancleBtn").get_text() == "解散房间")
             print('测试通过')
Beispiel #14
0
 def get_id(self):
     from until.ChangeDevs import ChangeDev
     selectDev = ChangeDev()
     selectDev.changedev()
     set_current(1)
     poco = StdPoco()
     userid = poco("lb_id").get_text().split(':')[1]
     return userid
Beispiel #15
0
 def Logout(self):
     time.sleep(1)
     dev=ChangeDev()
     dev.changedev()
     set_current(1)
     poco = StdPoco()
     keyevent("BACK")
     poco("btn_yes").click()
def login(accountpye):
    '''
    通用的切换账号的方法
    :param accountpye: 测试账号的编号
    :return:
    '''
    poco = StdPoco()
    text(data['login'][accountpye]['username'])  # 输入用户名
Beispiel #17
0
 def test_qinyoulist(self):
     u'亲友列表'
     poco=StdPoco()
     poco("btn_club").click()
     if poco("btn_clublist").exists():
         poco("btn_clublist").click()
         assert(poco("lab_title").get_text()=='亲友圈玩家')
         print('亲友圈玩家界面展示正常--测试通过')
Beispiel #18
0
 def test_entered(self):
     u'进入亲友圈'
     poco=StdPoco()
     time.sleep(1)
     poco("btn_club").click()
     poco("btn_clubRoom").click()
     assert(poco("Label_39").get_text()=='管理亲友圈房间模版')
     print('进入亲友圈功能--测试通过')
Beispiel #19
0
def popup():
    #实例化一次poco,一用全局初始化就报10053错,很是头疼
    poco = StdPoco()
    while True:
        try:
            poco("<Node | Tag = -1").chhild("<Layer | Tag = -1>").offspring("closeBtn").wait(timeout=1.5).click()
        except:
            log("真好没有拍脸,什么也不用干!")
            break
Beispiel #20
0
 def test_dhrecode(self):
     u'兑换记录 界面显示'
     poco = StdPoco()
     poco("lab").click()
     time.sleep(1)
     assert (poco("Layout")[1].offspring("btn_record").offspring(
         "lab").get_text() == '兑换记录')
     print('兑换记录界面显示正常--测试通过')
     poco("Layout")[1].offspring("btn_trophy").offspring("lab").click()
Beispiel #21
0
 def test_mianfei(self):
     '首页免费按钮跳转测试'
     poco = StdPoco()
     poco("btn_free").click()
     if poco("lb_des"):
         print('首页免费跳转功能正常--测试通过')
     else:
         print('首页免费跳转功能异常--测试失败')
         assert (poco("lb_des_0").get_text() == '每日限领一次(二选一)')
Beispiel #22
0
 def test_bd(self):
     '首页绑定跳转测试'
     poco = StdPoco()
     poco("btn_bind_phone").click()
     if poco("phone_title"):
         print('绑定跳转功能--测试通过')
     else:
         print('绑定跳转功能--测试失败')
         assert (poco("phone_title"))
Beispiel #23
0
 def test_quitroom(self):
     u'退出房间'
     getdev = ChangeDev()
     getdev.changedev()
     set_current(0)
     poco = StdPoco()
     poco("cancleBtn").click()
     poco("btn_yes").click()
     assert (poco("btn_new"))
     print('退出房间功能测试通过')
     set_current(1)
     keyevent('BACK')
     poco = StdPoco()
     poco("btn_yes").click()
     keyevent('BACK')
     poco("btn_yes").click()
     set_current(0)
     poco = StdPoco()
Beispiel #24
0
 def test_dismissroom_Cancel(self):
     u'取消解散房间'
     poco = StdPoco()
     poco("cancleBtn").click()
     dismiss_cancel = poco("<Label | Tag = -1, Label = '您是否要解散房间?'>")
     dismiss_cancel.wait_for_appearance()
     poco("btn_cancal").click()
     assert (poco("shardBtn").get_text() == '邀请好友')
     print('测试通过')
Beispiel #25
0
 def test_share(self):
     '首页分享界面弹出功能测试'
     poco = StdPoco()
     poco("btn_share").click()
     if poco("friend_group_btn").exists():
         print('分享界面弹出成功')
     else:
         print('分享界面弹出失败')
         assert (poco("friend_group_btn"))
Beispiel #26
0
 def test_set(self):
     '设置界面跳转测试'
     poco = StdPoco()
     poco("btn_more").click()
     poco("btn_setting").click()
     if poco("zhendong").exists():
         print('进入设置界面--测试通过')
     else:
         print('进入设置界面异常--测试失败')
         assert (poco("zhendong").get_text() == '震动')
Beispiel #27
0
 def test_setselecwjsound(self):
     '屏蔽玩家声音测试'
     poco = StdPoco()
     pb = poco("select_CheckBox")
     if pb.attr('enabled') == True:
         pb.click()
         print('屏蔽玩家语音选择正常--测试通过')
     else:
         print('无法勾选“屏蔽玩家语音”--测试失败')
         assert (pb.attr('enabled') == True)
Beispiel #28
0
 def test_dismissroom_Sure(self):
     u'解散房间'
     poco = StdPoco()
     poco("cancleBtn").click()
     dismiss = poco("<Label | Tag = -1, Label = '您是否要解散房间?'>")
     dismiss.wait_for_appearance()
     poco("btn_yes").click()
     time.sleep(5)
     assert (poco("btn_join"))
     print('测试通过')
Beispiel #29
0
 def test_kfdlcopy(self):
     '复制代理微信'
     poco = StdPoco()
     touch((922, 450), duration=0.1)
     if poco("root").offspring("txt"):
         if poco("root").offspring("txt").get_text() == '复制信息成功':
             print('复制代理招募--测试通过')
     else:
         print('复制代理招募异常--测试失败')
         assert (poco("root").offspring("txt"))
Beispiel #30
0
 def test_kf(self):
     '客服跳转功能测试'
     poco = StdPoco()
     poco("btn_more").click()
     poco("btn_help").click()
     if poco("Layout")[1].offspring("Label_8"):
         print('客服界面跳转正常--测试通过')
     else:
         print('客服界面跳转异常--测试失败')
         assert (poco("Layout")[1].offspring("Label_8"))