Example #1
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)
Example #2
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)