51Testing软件测试论坛
标题:
python+selenium 开源分享
[打印本页]
作者:
海鸥一飞
时间:
2018-2-7 15:21
标题:
python+selenium 开源分享
说明
之前分享过自己写的appium框架,有很多待优化的地方,先从selenium开始优化
功能
yaml维护用例
支持多检查点
excel记录报告,失败有截图展示
本地记录日志
参数化测试用例管理
用法
下载项目:
git clone git@github.com:Louis-me/selenium.git
复制代码
配置openurl.yaml
openurl: http://www....com/login
复制代码
配置用例yaml
testinfo:
- id: 001
moudle: mok模块
intr: 个人
testcase:
- element_info: //*[@id="login"]/div[1]/div[2]/form/div[1]/input
find_type: by_xpath
operate_type: send_keys
text: test
- element_info: //*[@id="login"]/div[1]/div[2]/form/div[2]/input
find_type: by_xpath
operate_type: send_keys
text: 123456
- element_info: //*[@id="login"]/div[1]/div[2]/form/button[1]
find_type: by_xpath
operate_type: click
check:
- element_info: //*[@id="home"]/a
find_type: by_xpath
- element_info: //*[@id="setting111"]/a
find_type: by_xpath
复制代码
用例管理
基本上是直接复制
PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(__file__), p)
)
from testRunner.runnerBase import TestInterfaceCase
class testSetting(TestInterfaceCase):
def setUp(self, methodName=''):
super(testSetting, self).setUp()
self.bc = webCase.WebCaseBase(driver=self.driver, casename="testSetting")
def tearDown(self):
self.driver.quit()
pass
def test_setting(self):
self.bc.execCase(PATH("../yaml/setting.yaml"))
复制代码
代码人口
def _report():
workbook = xlsxwriter.Workbook('report.xlsx')
worksheet = workbook.add_worksheet("测试总况")
worksheet2 = workbook.add_worksheet("测试详情")
re = report.OperateReport(wd=workbook)
re.init(worksheet, data=util.DATA)
re.test_detail(worksheet2, data=util.INFO)
re.close()
def runnerCaseWeb():
starttime = datetime.datetime.now()
suite = unittest.TestSuite()
suite.addTest(TestInterfaceCase.parametrize(testLogin)) # 引用测试用例类
suite.addTest(TestInterfaceCase.parametrize(testSetting))#引用测试用例类
unittest.TextTestRunner(verbosity=2).run(suite)
endtime = datetime.datetime.now()
util.DATA["sum_time"] = str((endtime - starttime).seconds) + "秒"
util.DATA["test_date"] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
if __name__ == '__main__':
runnerCaseWeb()
_report()
复制代码
命令行运行
pyhton testRunner/runner.py
复制代码
测试报告
[attach]110691[/attach]
[attach]110692[/attach]
作者:
梦想家
时间:
2018-5-14 16:53
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2