Beispiel #1
0
    def submit_suc(self, dict, assert_it):
        self.driver = reIdentified().reIdentifing(dict)
        try:
            closeMarketing(self.driver)
        except Exception as e:
            pass
        try:
            closeCarSetting(self.driver)
        except:
            pass
        WebDriverWait(self.driver, 30, 0.5).until(
            EC.presence_of_element_located(
                (By.ID, 'com.vcolco.undunion:id/tv_result')))
        result = self.driver.find_element_by_id(
            "com.vcolco.undunion:id/tv_result").text
        print result
        nowTime = time.strftime('%Y-%m-%d %H:%M:%S',
                                time.localtime(time.time()))
        if result in assert_it:
            write_log('\n' + nowTime + " reidentified sucessful" + '\n')
            #print '\n' + nowTime + " reidentified sucessful" + '\n'
            print colored(('\n' + nowTime + " reidentified sucessful" + '\n'),
                          "green")

        else:
            write_log(
                colored(('\n' + nowTime + " reidentified sucessful" + '\n'),
                        "red"))
            print colored(('\n' + nowTime + " reidentified sucessful" + '\n'),
                          "red")

        self.driver.quit()
Beispiel #2
0
    def loginByPasswordSuc(self,dict,assert_it):
        '''正确的手机号和密码'''
        self.driver=login().LoginByPassword(dict)

        try:
            closeMarketing(self.driver)
        except Exception as e:
            pass
        try:
            closeCarSetting(self.driver)
        except:
            pass
        WebDriverWait(self.driver, 30, 0.5).until(EC.presence_of_element_located((By.ID, 'com.vcolco.undunion:id/tvMoreTask')))
        result=self.driver.find_element_by_id("com.vcolco.undunion:id/tvMoreTask").text #查看任务列表
        #print result
        nowTime=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
        if result in assert_it:
            write_log('\n' + nowTime + " login sucessful" + '\n')
            #write_log(colored(('\n' + nowTime + " login sucessful" + '\n'), "red"))
            print  colored(('\n' + nowTime + " login sucessful" + '\n'), "green")
        else:
            write_log(colored(('\n' + nowTime + " login fail" + '\n'), "red"))
            print colored(('\n' + nowTime + " login fail" + '\n'), "red")


        self.driver.quit()
Beispiel #3
0
 def driven_it(self):
     ex=Excel()
     table=ex.read_it("C:\\Users\\Administrator\\PycharmProjects\\aapium\\tools\\testData.xlsx")
     i=1
     for rownum in range(1,table.nrows):
         print "\n##### start Test Case"+str(i)+"  ####"
         '''获取行数据为列表形式'''
         list=table.row_values(rownum)
         print(list)
         #动态导入包
         __import__('testCase.'+list[1])#import testCase.Login
         #  #导入模块
         module=sys.modules['testCase.'+list[1]]#change Login()
         # #根据list[0]获取类
         c=getattr(module,list[1])#c=Login()
         # #实例化对象
         obj=c()#obi=Login()
         # #根据list[1]获取方法
         mtd=getattr(obj,list[2])#mtd=assert_suc
         try:
             dict=get_dc(list[3])
             print dict
             if list[4]=="":
                 mtd(dict)
             else:
                 mtd(dict,list[4])
         except Exception as e:
             nowTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
             write_log(colored((nowTime+" error :"+str(e)+"\n"), "red"))
             print colored((nowTime+str(e)), "red")
             sys.exit()
         print("##### stop Test Case"+str(i)+"  ####\n")
         time.sleep(3)
         i+=1
Beispiel #4
0
    def createCar_suc(self,dict,assert_it):
        self.driver=createCar().createNewCar(dict)
        WebDriverWait(self.driver, 10, 0.5).until(
            EC.presence_of_element_located((By.ID, "com.vcolco.undunion:id/tv_statue")))
        result=self.driver.find_element_by_id("com.vcolco.undunion:id/tv_statue").text
        nowTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
        if assert_it in result:

            write_log('\n' + nowTime + " create car sucessful" + '\n')
            #print '\n' + nowTime + " create car sucessful" + '\n'
            print  colored(('\n' + nowTime + " create car sucessful" + '\n'), "green")

        else:
            write_log(colored(('\n' + nowTime + " create car fail" + '\n'), "red"))
            print colored(('\n' + nowTime + " create car fail" + '\n'), "red")
        self.driver.quit()
Beispiel #5
0
    def changePasswordSuc(self, dict, assert_it):
        self.driver = changePassword().changePassword(dict)

        try:
            closeMarketing(self.driver)
        except Exception as e:
            pass
        try:
            closeCarSetting(self.driver)
        except:
            pass
        WebDriverWait(self.driver, 30, 0.5).until(
            EC.presence_of_element_located(
                (By.ID, 'com.vcolco.undunion:id/tvMoreTask')))
        result = self.driver.find_element_by_id(
            "com.vcolco.undunion:id/tvMoreTask").text  #查看任务列表
        #print result
        nowTime = time.strftime('%Y-%m-%d %H:%M:%S',
                                time.localtime(time.time()))
        if result in assert_it:
            write_log('\n' + nowTime + " change password sucessful" + '\n')
            #write_log(colored(('\n' + nowTime + " login sucessful" + '\n'), "red"))
            print colored(
                ('\n' + nowTime + " change password sucessful" + '\n'),
                "green")
        else:
            write_log(
                colored(('\n' + nowTime + " change password fail" + '\n'),
                        "red"))
            print colored(('\n' + nowTime + " change password fail" + '\n'),
                          "red")

        self.driver.quit()


#dict={"phone":"18782256120","password":"******"}
#f=ChangePassword()
#f.changePasswordSuc(dict,u"查看任务列表")
Beispiel #6
0
    def switch_suc(self,dict):
        #self.driver=switchCar().changeCar(dict)
        self.driver = login().LoginByPassword(dict)
        try:
            closeMarketing(self.driver)
        except Exception as e:
            pass
        try:
            closeCarSetting(self.driver)
        except:
            pass
        try:
            taskStatus=self.driver.find_element_by_id("com.vcolco.undunion:id/tvTaskStatus").text
            if u"执行中"==taskStatus:
                nowTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
                write_log(colored(('\n' + nowTime + u" 当前车辆正在使用中,暂时无法换车" + '\n'), "red"))
                print colored(('\n' + nowTime + u" 当前车辆正在使用中,暂时无法换车" + '\n'), "red")

        except:
            WebDriverWait(self.driver, 30, 0.5).until(
                lambda x: x.find_element_by_id("com.vcolco.undunion:id/iv_back")).click()  # 进入侧边栏
            self.driver.find_element_by_name(u"车辆管理").click()  # 车辆管理
            try:
                if self.driver.find_element_by_id("com.vcolco.undunion:id/tv_net_error"):
                    nowTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
                    write_log(colored(('\n' + nowTime + u" 当前司机暂无车辆可使用,暂时无法换车" + '\n'), "red"))
                    print colored(('\n' + nowTime + u" 当前司机暂无车辆可使用,暂时无法换车" + '\n'), "red")


            except:
                WebDriverWait(self.driver, 30, 0.5).until(
                    EC.presence_of_element_located((By.ID, 'com.vcolco.undunion:id/btnSwitchCar')))
                self.driver.find_element_by_id("com.vcolco.undunion:id/btnSwitchCar").click()  # 选择当前用车

                try:
                    nowTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
                    result = self.driver.find_element_by_id("com.vcolco.undunion:id/tvTips").text
                    write_log(colored(('\n' + nowTime + u" 当前车辆正在使用中,暂时无法换车" + '\n'), "red"))
                    print colored(('\n' + nowTime + u" 当前车辆正在使用中,暂时无法换车" + '\n'), "red")

                except:
                    WebDriverWait(self.driver, 30, 0.5).until(
                        EC.presence_of_element_located((By.ID, 'com.vcolco.undunion:id/tvPlatNum')))
                    carList = self.driver.find_elements_by_id("com.vcolco.undunion:id/tvPlatNum")  # 获取当前所有车辆
                    #i = 0
                    print len(carList)
                    while 1:
                        i=1
                        for car in carList:

                            car.click()  # 循环点击车辆
                            licensePlateNumber=car.text#获取当前车辆车牌号
                            #print licensePlateNumber
                            self.driver.find_element_by_id("com.vcolco.undunion:id/btnSwitchCar").click()  # 确认切换
                            context = self.driver.find_element_by_id("com.vcolco.undunion:id/tvTips").text  # 判断当前的车辆是否已被人使用
                            if u"该车目前暂无人使用,是否确定换车" in context:
                                self.driver.find_element_by_id("com.vcolco.undunion:id/btnRight").click()  # 点击确定
                                i = 0
                                WebDriverWait(self.driver, 30, 0.5).until(
                                    EC.presence_of_element_located((By.ID, 'com.vcolco.undunion:id/top_tv_plate')))
                                nowLicensePlateNumber=self.driver.find_element_by_id("com.vcolco.undunion:id/top_tv_plate").text
                                nowTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
                                if licensePlateNumber==nowLicensePlateNumber:
                                    write_log('\n'+nowTime + " SwitchCar sucessful" + '\n')
                                    #print nowTime + " SwitchCar sucessful"
                                    print  colored(('\n' + nowTime + " SwitchCar sucessful" + '\n'), "green")
                                break
                            else:
                                self.driver.find_element_by_id("com.vcolco.undunion:id/btnLeft").click()#点击再等一下
                                #carList.remove(car)


                        if i == 1:
                            #width = self.driver.manage().window().getSize().width  # 获取当前手机分辨率
                            #height = self.driver.manage().window().getSize().height
                            #width =self.driver.get_window_size()['height']# 获取当前手机分辨率
                            #height =self.driver.get_window_size()['width']# 获取当前手机分辨率
                            str1 = self.driver.page_source()  # 滑动前获取pagesource
                            print str1
                            swipeDown(self.driver,1)
                            str2 = self.driver.page_source()  # 滑动后获取pagesource
                            print str2
                            nowTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
                            if str1 == str2:
                                write_log(colored(('\n' + nowTime + u" 当前无车可换" + '\n'), "red"))
                                print colored(('\n' + nowTime + u" 当前无车可换" + '\n'), "red")
                                break

                            else:
                                carList.append(self.driver.find_elements_by_class_name("android.widget.LinearLayout"))

                        else:
                            break
        self.driver.quit()





#dict={"phone":"13730687504","password":"******"}
#f=SwitchCar()
#f.switch_suc(dict)