Example #1
0
 def test_1Search(self):
     self.autoDriver.click("xpath|" + getCellValue(0, 4, 2, excel_path))
     self.autoDriver.click("xpath|" + getCellValue(0, 5, 2, excel_path))
     self.autoDriver.send_keys("xpath|" + getCellValue(0, 6, 2, excel_path),
                               "李维辉")
     self.autoDriver.send_keys("xpath|" + getCellValue(0, 7, 2, excel_path),
                               "")
     self.autoDriver.send_keys("xpath|" + getCellValue(0, 8, 2, excel_path),
                               "")
     self.autoDriver.click("xpath|" + getCellValue(0, 9, 2, excel_path))
     logger.info('查询出符合条件的记录!数据校验中...')
Example #2
0
 def test_2Rest(self):
     self.autoDriver.click("xpath|" + getCellValue(0, 4, 2, excel_path))
     self.autoDriver.click("xpath|" + getCellValue(0, 5, 2, excel_path))
     self.autoDriver.send_keys("xpath|" + getCellValue(0, 6, 2, excel_path),
                               "潘献军")
     self.autoDriver.send_keys("xpath|" + getCellValue(0, 7, 2, excel_path),
                               "")
     self.autoDriver.send_keys("xpath|" + getCellValue(0, 8, 2, excel_path),
                               "")
     self.autoDriver.click("xpath|" + getCellValue(0, 10, 2, excel_path))
     logger.info('成功执行重置操作!')
     time.sleep(5)
Example #3
0
 def setUpClass(self):
     self.autoDriver = webutils()
     self.autoDriver.max_window()
     self.base_url = "http://10.2.5.139:9000/#/login"
     self.autoDriver.get(self.base_url)
     self.autoDriver.wait(5)
     self.autoDriver.send_keys("xpath|" + getCellValue(0, 1, 2, excel_path),
                               "test01")
     self.autoDriver.send_keys("xpath|" + getCellValue(0, 2, 2, excel_path),
                               "123456")
     self.autoDriver.click("xpath|.//parent::button")
     logger.info('登录成功!')
Example #4
0
 def getValue(self, response, param):
     try:
         if response.status_code != 200:
             print('请求失败:', response.status_code)
         else:
             if param.lower() == 'token':
                 return response.json()['loginInfo']['tokenVo']['token']
             elif param.lower() == 'status':
                 return response.json()['result']['status']
             elif param.lower() == 'userid':
                 return response.json()['loginInfo']['userId']
             elif param.lower() == 'message':
                 return response.json()['result']['message']
             elif param.lower() == 'targetid':
                 return response.json()['loginInfo']['targetId']
             elif param.lower() == 'userid':
                 return response.json()['loginInfo']['userId']
     except Exception as e:
         print(format(e))
         logger.info(e)
Example #5
0
 def requests(self, httpMethod, url, data,
              headers):  # 定义一个方法,传入需要的参数url和data
     # 参数必须按照url、data顺序传入
     if httpMethod.lower() == ('post'):  #.upper()小写转大写
         try:
             if isinstance(data, str):  #判断数据类型,类型为str则不需要转格式
                 result = requests.post(url=url,
                                        data=data,
                                        headers=headers,
                                        verify=False)
             else:
                 result = requests.post(url=url,
                                        data=json.dumps(data),
                                        headers=headers,
                                        verify=False)
             return result
         except BaseException as e:
             print("post请求出现了异常:{0}".format(e))
     elif httpMethod.lower() == ('get'):
         try:
             if isinstance(data, str):
                 result = requests.get(url=url,
                                       params=data,
                                       headers=headers,
                                       verify=False)
             else:
                 #数据格式转换
                 result = requests.get(url=url,
                                       params=json.dumps(data),
                                       headers=headers,
                                       verify=False)
             return result
         except Exception as e:
             print("get请求出现了异常:{0}".format(e))
             logger.exception(format(e))
     else:
         print("method值错误:", httpMethod)
         logger.info("method值错误:", httpMethod)
Example #6
0
    #列举test_dir目录下的所有文件,结果以列表形式返回。
    lists = os.listdir(dir_of_report)
    #sort按key的关键字进行排序,lambda的入参fn为lists列表的元素,获取文件的最后修改时间
    #最后对lists元素,按文件修改时间大小从小到大排序。
    lists.sort(key=lambda fn: os.path.getmtime(dir_of_report + '\\' + fn))
    #获取最新文件的绝对路径
    file_path = os.path.join(dir_of_report, lists[-1])
    return file_path


#4. 执行用例
if __name__ == '__main__':
    print('=====AutoTest Start======')
    now = time.strftime('%Y-%m-%d_%H_%M_%S_')
    if sys.argv[1] == '1':
        logger.info('Begin to API Testing!')
        filename = './Report/' + '\\' + now + 'API_Result.html'
    elif sys.argv[1] == '2':
        logger.info('Begin to UI Testing!')
        filename = './Report/' + '\\' + now + 'UI_Result.html'
    fp = open(filename, 'wb')
    runner = HTMLTestRunner(stream=fp,
                            title=u'Test Report',
                            description=u'Case Execution Details:')
    runner.run(discover)
    logger.info('Building Test Report Success!')
    fp.close()
    logger.info('Ready to Sending Mail!')
    mymail = MyMail('./config/mail.conf')
    mymail.connect()
    mymail.login()
Example #7
0
    config = configparser.ConfigParser()
    config.read('./config/report.conf', encoding='utf-8')
    dir_of_report = config['REPORT']['dir_of_report']
    #列举test_dir目录下的所有文件,结果以列表形式返回。

    lists = os.listdir(dir_of_report)
    #sort按key的关键字进行排序,lambda的入参fn为lists列表的元素,获取文件的最后修改时间
    #最后对lists元素,按文件修改时间大小从小到大排序。
    lists.sort(key=lambda fn: os.path.getmtime(dir_of_report))
    #获取最新文件的绝对路径
    file_path = os.path.join(dir_of_report, lists[-1])
    return file_path


if __name__ == '__main__':

    print new_file()
    mymail = MyMail('./config/mail.conf')
    mymail.connect()
    mymail.login()
    mail_content = 'Hi,Attachments Is Test Report,Please Refer .'
    mail_tiltle = '[Test Report]Test Report'
    #根据配置文件读取测试报告路径,并通过newfile获取最新的测试报告作为附件发送,代码下周更新
    #attachments = set('./Report/')
    logger.info('Building Test Report Success!')
    #attachments = new_file()
    attachments = set([new_file()])
    logger.info('Test Report Sending...')
    mymail.send_mail(mail_tiltle, mail_content, attachments)
    mymail.quit()
    logger.info('Sending Success!')