# -*- coding: utf-8 -* import requests import unittest import os, sys sys.path.append(os.path.abspath(__file__)) parent_dir = os.path.dirname(os.path.dirname( os.path.abspath(__file__))) # 父路径-Auto sys.path.insert(0, parent_dir) from pprint import pprint from DB import UseDataBase import time from ForUse import read_ini, app_miyao, app_login ini_path = parent_dir + '/user.ini' config = read_ini(ini_path) config.read(ini_path, encoding='utf-8') user_login = eval(config.get(section='user', option='chq')) # 登录账号 user_register = eval(config.get(section='user', option='register')) # 注册账号 class Center_Product(unittest.TestCase): """center_product服务接口(小刚)""" def setUp(self): self.session = requests.session() self.ip = 'http://139.196.107.14:9000' self.ym = 'https://www-t.jfcaifu.com' self.signature = app_miyao() # @unittest.skip('跳过') def test_app_homepage(self): """APP首页标列表"""
# -*- coding: utf-8 -* import requests import unittest from pprint import pprint import os, sys sys.path.append(os.path.abspath(__file__)) parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # 父路径-Auto sys.path.insert(0, parent_dir) from DB import UseDataBase from ForUse import read_ini config = read_ini(ini_path=parent_dir + '/user.ini') user = eval(config.get(section='user', option='chq')) class Activity(unittest.TestCase): """日常活动""" def setUp(self): self.yuming = 'https://www-t.jfcaifu.com' self.session = requests.session() # -------------------------------------------回归用的登陆账号---------------------------------------------------- self.phone = user['username'] # 日常回归用登录账号 self.pwd = user['password'] # -------------------------------------------【注册专用】账号---------------------------------------------------- self.register_phone = '17302188888' # 注册专用账号 self.register_pwd = 'a1234567' def tearDown(self):
driver.find_element_by_link_text(u'初审').click() driver.switch_to.default_content() time.sleep(1) check_status = self.config['check_status'] if check_status == '通过': driver.find_element_by_css_selector('[value="1"]').click() elif check_status == '不通过': driver.find_element_by_css_selector('[value="0"]').click() else: driver.find_element_by_css_selector('[value="101"]').click() driver.find_element_by_link_text(u"确定").click() # 建标完成 time.sleep(2) driver.find_element_by_link_text(u"确定").click() # 关闭弹窗:操作成功! time.sleep(2) except Exception as err: filename = '../Picture/%s.jpg' % time.strftime( "%Y.%m.%d %H.%M.%S", time.localtime()) driver.save_screenshot(filename) print(err) finally: driver.quit() if __name__ == '__main__': print(parent_dir) ini_path = parent_dir + '/borr.ini' config = eval(read_ini(ini_path).get(section='borrow', option='config')) pprint(config) fb = Manage(config) fb.Fa_Biao()
sys.path.append(parent_dir) sys.path.append(os.path.abspath(__file__)) sys.path.append('./') from HTMLTestRunner import HTMLTestRunner import unittest from ForUse import Report_Mail, read_ini # 指定测试用例为当前目录下的Case_UI目录 test_dir = parent_dir + '/Case_UI' discover = unittest.defaultTestLoader.discover(test_dir, pattern='jf*.py') if __name__ == '__main__': now = time.strftime('%Y-%m-%d %H_%M_%S') filename = './Report_UI/' + now + '_result.html' fp = open(filename, 'wb') runner = HTMLTestRunner(stream=fp, title='曹华强自动化测试报告(UI)', description='UI自动化测试报告') # runner = unittest.TextTestRunner() runner.run(discover) fp.close() report_dict = parent_dir + '/Report_UI/' rm = Report_Mail(report_dict) Email = eval( read_ini(parent_dir + '/user.ini').get(section='Email', option='email')) rm.send_mail(receiver=[ Email['chq'], ])