#coding=utf-8 #author='Shichao-Dong' import time, os from appium import webdriver from comm.Log import Logger from selenium.common.exceptions import WebDriverException from comm.StartAppiumServer import Sp from comm.readConfig import ReadConfig conf = ReadConfig() log = Logger() app_path = os.path.join(os.path.abspath(os.path.join(os.getcwd(), "../..")), 'UI-Test', 'comm', 'apps', 'cibn.apk') platformName = conf.get_config('platformName') appPackage = conf.get_config('appPackage') appActivity = conf.get_config('appActivity') appium_port = conf.get_config('appium_port') class webDriver: def __init__(self): self.get_device = conf.get_cmd('viewDevices') self.get_Version = conf.get_cmd('platformVersion') self.startServer = conf.get_cmd('startServer') def get_deviceName(self): values = os.popen(self.get_device).readlines() print(values) dev = values[1].split()[0]
#!/usr/bin/env python # -*- coding:utf-8 -*- # @Time : 2019/5/27 16:57 # @Author: dongyani # @File : runAll.py import time, os, unittest, comm.Log import comm.HTMLTestRunner_cn as HTMLTestRunner from comm.configEmail import send_email from comm.readConfig import ReadConfig send_mail = send_email() on_off = ReadConfig().get_email('on_off') retry = int(ReadConfig().get_test('retry')) log = comm.Log.Logger() # 这个是优化版执行所有用例并发送报告,分四个步骤 # 第一步加载用例 # 第二步执行用例 # 第三步获取最新测试报告 # 第四步发送邮箱 (这一步不想执行的话,可以注释掉最后面那个函数就行) # 当前脚本所在文件真实路径 cur_path = os.path.dirname(os.path.realpath(__file__)) + "\\testSmoke" def all_case(): testcase = unittest.TestSuite() discover = unittest.defaultTestLoader.discover(cur_path, pattern="test*.py", top_level_dir=None) # discover方法筛选出来的用例,循环添加到测试套件中
# -*- coding:utf-8 -*- #@Time : 2019/9/16 15:21 #@Author: yanghuiyu #@Function:stream import unittest, time import comm.common as common from comm.webDriver import webDriver from pageElement.homePage import homepage from comm.readConfig import ReadConfig from pageElement.base_element_operate import base telephone = ReadConfig().get_app("telephone") class Stream(unittest.TestCase): @classmethod def setUpClass(cls): #打开应用,进入首页 cls.driver = webDriver().get_driver() base(cls.driver).start_login_app() base(cls.driver).bottom_navigation("首页") pass @classmethod def tearDownClass(cls): cls.driver.close_app() pass # 4 def test_01_play_home_stream(self):
# -*- coding:utf-8 -*- #@Time : 2019/9/16 18:30 #@Author: pengjuan #@Function: vip import unittest import comm.common as common from comm.webDriver import webDriver from pageElement.base_element_operate import base from comm.readConfig import ReadConfig appPackage = ReadConfig().get_config("appPackage") class Vip(unittest.TestCase): @classmethod def setUpClass(cls): #打开应用,进入 cls.driver = webDriver().get_driver() base(cls.driver).start_app() base(cls.driver).bottom_navigation("会员").click() pass @classmethod def tearDownClass(cls): cls.driver.remove_app(appPackage) pass # 34 def test_01_vip_page(self): """在vip页面,查看显示正常"""
#!/usr/bin/env python # -*- coding:utf-8 -*- #@Time : 2019/9/3 16:57 #@Author: dongyani from comm.Log import Logger from comm.readConfig import ReadConfig import time, os conf = ReadConfig() log = Logger() appium_port = conf.get_config('appium_port') class Sp(): def stop_appium(self): '''关闭appium服务''' # if pc.upper() == 'WIN': p = os.popen(f'netstat -aon|findstr {appium_port}') p0 = p.read().strip() print(f"appium进程信息:{p0}") if p0 != '' and 'LISTENING' in p0: p1 = int(p0.split('LISTENING')[1].strip()[0:4]) # 获取进程号 # print(p1) os.popen(f'taskkill /F /PID {p1}') # 结束进程 print('appium server进程已结束') # elif pc.upper() == 'MAC': # p = os.popen(f'lsof -i tcp:{post_num}') # p0 = p.read() # if p0.strip() != '': # p1 = int(p0.split('\n')[1].split()[1]) # 获取进程号
#!/usr/bin/env python # -*- coding:utf-8 -*- #@Time : 2019/5/27 16:52 #@Author: dongyani #@File : configEmail.py """ 这个文件主要是配置发送邮件的主题、正文等,将测试报告发送并抄送到相关人邮箱的逻辑。 """ import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from comm.readConfig import ReadConfig read_conf = ReadConfig() sender = read_conf.get_email('sender') psw = read_conf.get_email('psw') receiver = read_conf.get_email('receiver') smtpserver = read_conf.get_email('smtp_server') port = read_conf.get_email('port') class send_email(): # get receiver list def many_receiver(self): receivers = [] for n in str(receiver).split(","): receivers.append(n) return receivers
# -*- coding:utf-8 -*- #@Time : 2019/9/16 15:56 #@Author: dongyani #@Function: video import unittest, time from comm.webDriver import webDriver import comm.common as common from comm.readConfig import ReadConfig from pageElement.base_element_operate import base from pageElement.homePage import homepage appPackage = ReadConfig().get_config("appPackage") video_title = ReadConfig().get_app('video_title') class Video(unittest.TestCase): @classmethod def setUpClass(cls): #打开应用,进入首页 cls.driver = webDriver().get_driver() base(cls.driver).start_login_app() base(cls.driver).bottom_navigation("首页") pass @classmethod def tearDownClass(cls): cls.driver.close_app() pass # 4
# -*- coding:utf-8 -*- #@Time : 2019/9/2 16:23 #@Author: dongyani #@Function:startup & upgrade import unittest import comm.common as common from comm.webDriver import webDriver from comm.readConfig import ReadConfig from pageElement.base_element_operate import base global upgrade upgrade = ReadConfig().get_test("upgrade") appPackage = ReadConfig().get_config("appPackage") class Startup(unittest.TestCase): @classmethod def setUpClass(cls): cls.driver = webDriver().get_driver() pass @classmethod def tearDownClass(cls): cls.driver.remove_app(appPackage) pass # 1,2 def test_01_startapp(self): """验证三个引导页面,点击立即体验,进入首页""" base(self.driver).start_login_app()