def test_click_message(self):
     '''
     这里一定要以test开头,把测试逻辑封装到一个test开头的方法里面。
     :return:
     '''
     request_message = Home(self.driver)
     try:
         request_message.click_xinlingshou()
         request_message.get_windows_img()  #
         time.sleep(3)
         get_messages = request_message.get_message_lists()
         request_message.get_windows_img()  #
         for i in get_messages:
             el_text = i.text
             print(el_text)
     except Exception as e:
         print("Cant find xinlingshou's message,%s" % e)
Exemple #2
0
 def test_delete_chat(self):
     '''
     这里一定要以test开头,把测试逻辑封装到一个test开头的方法里面。
     :return:
     '''
     long_delete = Home(self.driver)
     try:
         long_delete.long_press_last_message()
         long_delete.get_windows_img()  #
         long_delete.delete_message()
         long_delete.click_delete_btn()
         long_delete.get_windows_img()  #
         time.sleep(2)
     except Exception as e:
         print("Cant find xinlingshou's message,%s" % e)
 def test_stick_chat(self):
     '''
     这里一定要以test开头,把测试逻辑封装到一个test开头的方法里面。
     :return:
     '''
     long_stick = Home(self.driver)
     try:
         before_home_name = long_stick.get_last_message_name()
         # print(before_home_name)
         long_stick.long_press_last_message()
         long_stick.get_windows_img()  #
         print(long_stick.get_lens_chat())
         if long_stick.get_lens_chat() == 3:
             long_stick.stick_chat(num=1)
         else:
             long_stick.stick_chat(num=0)
         after_home_name = long_stick.get_first_message_name()
         long_stick.get_windows_img()  #
         if before_home_name == after_home_name:
             print("会话置顶成功!")
         else:
             print("会话置顶失败!")
     except Exception as e:
         print("Cant find xinlingshou's message,%s" % e)
Exemple #4
0
    def test_task_delay(self):
        '''
        这里一定要以test开头,把测试逻辑封装到一个test开头的方法里面。
        :return:
        缺陷:目前只能实现当前日期在29号之前的日期,后续优化
        '''
        delay_task = Home(self.driver)
        try:
            before_total_card = delay_task.card_total_num()
            delay_task.get_windows_img()  #
            delay_task.click_delay_btn()
            current_time = time.strftime('%Y-%m-%d %H:%M:%S',
                                         time.localtime(time.time()))
            print(current_time)
            current_time_day = current_time.split(" ")[0].split("-")[2]
            text = '任务已延期,延期时间:' + current_time
            delay_task.type_delay_reason(text)
            time.sleep(3)
            if int(current_time_day) < 29:
                delta_day = 0
                i = 0
                while delta_day < 1:
                    delay_task.click_delay_time()
                    time.sleep(2)
                    delay_task.swipe_delay_day(i)
                    time.sleep(1)
                    delay_task.click_delay_time_sure()
                    time.sleep(1)
                    delay_time = delay_task.get_delay_time()
                    current_delay_time = datetime.datetime.strptime(
                        delay_time, '%Y-%m-%d %H:%M')
                    now_time = time.strftime('%Y-%m-%d %H:%M',
                                             time.localtime(time.time()))
                    current_time = datetime.datetime.strptime(
                        now_time, '%Y-%m-%d %H:%M')
                    delta = current_delay_time - current_time
                    delta_day = delta.days
                    time.sleep(2)
                    i = i + 2
                delay_task.get_windows_img()
                delay_task.click_complete_btn()
            delay_task.get_windows_img()
            # else:
            #     delay_task.click_delay_time()
            #     time.sleep(2)
            #     delay_task.swipe_delay_month()
            #     time.sleep(1)
            #     delay_task.click_delay_time_sure()
            #     time.sleep(1)

            after_total_card = delay_task.card_total_num()
            if int(after_total_card) == int(before_total_card) - 1:
                print("自动操作延期任务成功!")
            else:
                print("自动操作延期任务失败!")
        except Exception as e:
            print("Can't find the card,%s" % e)
Exemple #5
0
 def test_task_complete(self):
     '''
     这里一定要以test开头,把测试逻辑封装到一个test开头的方法里面。
     :return:
     '''
     complete_task = Home(self.driver)
     try:
         time.sleep(5)
         #获取当前页面的卡片的总数量
         before_total_card = complete_task.card_total_num()
         complete_task.click_colligate_btn()
         time.sleep(3)
         complete_task.change_input_method('appium')
         time.sleep(2)
         #填写完成理由
         current_time = time.strftime('%Y-%m-%d %H:%M:%S',
                                      time.localtime(time.time()))
         text = '任务已完成,完成时间:' + current_time
         complete_task.type_colligate_text(text)
         time.sleep(3)
         complete_task.get_windows_img()  #
         complete_task.click_complete_btn()
         #获取页面的toast
         complete_task.get_toast_text("完成")
         complete_task.get_windows_img()  #
         #如果页面卡片的数量减少,延期任务成功
         after_total_card = complete_task.card_total_num()
         if int(after_total_card) == int(before_total_card) - 1:
             print("自动操作完成任务成功!")
         else:
             print("自动操作完成任务失败!")
     except Exception as e:
         print("Can't find the card,%s" % e)
Exemple #6
0
 def test_send_message(self):
     '''
     这里一定要以test开头,把测试逻辑封装到一个test开头的方法里面。
     :return:
     '''
     send_message = Home(self.driver)
     try:
         send_message.click_chat(i=2)
         send_message.get_windows_img()
         current_time = time.strftime('%Y-%m-%d %H:%M:%S',
                                      time.localtime(time.time()))
         text = '测试自动聊天,发送时间:' + current_time
         send_message.type_chat_box(text)
         # send_message.change_input_method("sogou")  #切换至搜狗输入法
         time.sleep(3)
         send_message.click_chat_box()
         time.sleep(2)
         send_message.click_send_btn()
         time.sleep(2)
         last_message_text = send_message.get_last_message_text(i=-1)
         send_message.get_windows_img()  #
         if text == last_message_text:
             print("会话发送成功!")
         else:
             print("会话发送失败。")
         time.sleep(3)
     except Exception as e:
         print("Cant find xinlingshou's message,%s" % e)
 def test_task_swipe(self):
     '''
     这里一定要以test开头,把测试逻辑封装到一个test开头的方法里面。
     :return:
     '''
     look_card = Home(self.driver)
     try:
         #获取页面卡片的数量,如果数量大于1就左右滑动
         card_total = look_card.card_total_num()
         look_card.get_windows_img()
         if int(card_total) > 1:
             before_card_num = look_card.card_current_num()
             print(before_card_num)
             look_card.swipe_left_card()
             time.sleep(3)
             after_card_num = look_card.card_current_num()
             print(after_card_num)
             if int(after_card_num) == int(before_card_num) + 1:
                 print("延期卡片左滑成功!")
             else:
                 print("延期卡片左滑失败。")
             look_card.get_windows_img()
         else:
             print("There is  only one card")
     except Exception as e:
         print("Can't find yhe card,%s" % e)