├── .DS_Store
├── .gitignore
├── README.md
├── data
├── __init__.py
├── config.ini
└── config.py
├── drivers
├── IEDriverServer.exe
├── chromedriver.exe
└── phantomjs.exe
├── report
├── HTMLTestRunner3.py
├── css
│ └── bootstrap.min.css
├── js
│ └── echarts.common.min.js
├── result.html
└── screenshot
│ └── test.txt
├── requirements.txt
├── run.py
├── screenshots
└── vantpy2.1.jpg
├── test
├── .DS_Store
├── Autolt
│ ├── test1.exe
│ └── test1.jpg
├── __init__.py
├── common
│ ├── BrowserDriver.py
│ ├── Seleniums.py
│ └── __init__.py
├── page
│ ├── BaiduPage.py
│ └── __init__.py
├── request
│ └── token.py
├── sqlserver
│ ├── __init__.py
│ ├── server.py
│ └── user.xlsx
└── testcase
│ ├── __init__.py
│ ├── case_modle.py
│ └── test_Baidu.py
├── utils
├── __init__.py
├── __pycache__
│ ├── __init__.cpython-39.pyc
│ └── readFile.cpython-39.pyc
├── assertion.py
├── config.py
├── generator.py
├── logger.py
└── readFile.py
└── vantpy2.0.emmx
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G2Bent/Vantpy/37369b8494b79ca60c99593fe3c75981035c8ec1/.DS_Store
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea
2 | /__pycache__
3 | /logs
4 | /.pytest_cache
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ##
**Vantpy2.0**
2 |
3 | #### vantpy的目标
4 | - 实现web UI自动化测试
5 | - 嵌套locust集成性能测试
6 | - 实现request接口测试
7 | - 通过ssh访问数据库
8 | - fastapi编写接口api自定义测试
9 |
10 | #### 关于更新1.21
11 |
12 | Vantpy更新的内容:
13 | 1. 兼容Linux系统,mac系统,跨系统使用,多人协作
14 | 2. 删除绝对路径的读取,改为相对路径的读取
15 | 3. 加入接口测试模块
16 | 4. 集成Jenkins,测试报告采用Allure测试报告
17 | 5. 添加随机生成器,使测试用例更灵活
18 | 6. 对selenium二次开发添加新的操作
19 | 7. 实现有界面与无界面之间的切换
20 |
21 | 
22 | -------------------------------
23 |
24 | #### demo 脚本
25 | - 把框架代码拉下来之后: `https://github.com/G2Bent/Vantpy.git`
26 | - 安装所依赖的第三方库: ` pip install requirements.txt`
27 | - 直接运行run.py文件
28 |
29 |
30 | #### 安装
31 |
32 | ---
33 |
34 | #### 关于框架:
35 |
36 | Vantpy框架基于python3+selenium+unittest搭建的WebUI自动化测试框架
37 |
38 | #### 特点:
39 |
40 | - 使用POM(页面对象模式)设计,使代码更加有逻辑性,测试脚本更加规范,后期更加容易维护以及复用性更高
41 | - 支持多种定位方式,包括(xpath/css/ID/text/link_text/name)
42 | - 框架集成了Selenium的常用定位方法,使元素定位更加方便
43 | - 使用HTMLTestRunner作为自动生成测试报告,报告更加美观,更加详细,内容更丰富
44 | - Logging日志输出,可以看到每一步做的操作
45 |
46 | #### 部署环境:
47 |
48 | - Python 3.6+:https://www.python.org/
49 |
50 | #### 使用到的package:
51 |
52 | > pip install requirements.txt
53 |
54 | #### 支持的浏览器及驱动:
55 |
56 | 基于Selenium支持的所有浏览器
57 |
58 | ```
59 | browser == "Chrome"
60 | browser == "firefox"
61 | browser == "IE"
62 | browser == "phantomjs"
63 | browser == "opera"
64 | browser == "edge"
65 | ```
66 |
67 | geckodriver(Firefox):https://github.com/mozilla/geckodriver/releases
68 |
69 | Chromedriver(Chrome):https://sites.google.com/a/chromium.org/chromedriver/home
70 |
71 | IEDriverServer(IE):http://selenium-release.storage.googleapis.com/index.html
72 |
73 | operadriver(Opera):https://github.com/operasoftware/operachromiumdriver/releases
74 |
75 | MicrosoftWebDriver(Edge):https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver
76 |
77 | #### 定位元素方式:
78 |
79 | ```
80 | class BaiduPage(BasePage):
81 | """
82 | 在这里写定位器,通过元素属性定位元素对象
83 | """
84 | search_loc =(By.XPATH,'//*[@id="kw"]')#定位百度文本框
85 |
86 | def input_baidu_text(self,text):
87 | self.send_key(self.search_loc,text)
88 | ```
89 |
90 | #### 日志输出
91 |
92 | ```
93 | 2018-06-02 14:58:13,521 - INFO - You had select Chrome browser.
94 | 2018-06-02 14:58:13,524 - INFO - The test url is: https://www.baidu.com
95 | 2018-06-02 14:58:19,629 - INFO - Starting Chrome browser.
96 | 2018-06-02 14:58:20,456 - INFO - Open url: https://www.baidu.com
97 | 2018-06-02 14:58:21,607 - INFO - Maximize the current window.
98 | 2018-06-02 14:58:21,609 - INFO - Set implicitly wait 5 seconds.
99 | 2018-06-02 14:58:21,609 - INFO - Clear input-box: //*[@id="kw"]...
100 | 2018-06-02 14:58:22,723 - INFO - Input element by xpath: //*[@id="kw"]...
101 | 2018-06-02 14:58:22,723 - INFO - Input: selenium
102 | ```
103 |
104 | #### 生成测试报告
105 |
106 | ```
107 | def report():
108 | if len(sys.argv) > 1:
109 | report_name = os.path.dirname(os.getcwd()) + '\\report\\' + sys.argv[1] + '_result.html'
110 | else:
111 | now = time.strftime("%Y-%m-%d_%H_%M_%S_")
112 | # 需要查看每段时间的测试报告,可以这样写:
113 | # report_name = os.getcwd() + '\\report\\'+now+'result.html'
114 | report_name = os.path.dirname(os.getcwd()) + '\\report\\result.html'
115 | return report_name
116 |
117 | fp = open(report(), 'wb')
118 | Runner = HTMLTestRunner(
119 | stream=fp,
120 | title='测试报告',
121 | description='测试用例执行情况'
122 | )
123 | ```
124 |
125 | #### 测试报告
126 |
127 | 
128 |
129 |
130 |
--------------------------------------------------------------------------------
/data/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding:utf-8 -*-
3 |
--------------------------------------------------------------------------------
/data/config.ini:
--------------------------------------------------------------------------------
1 | [browserType]
2 | browserName = Firefox
3 |
4 | [ptahUrl]
5 | URL=https://www.baidu.com
--------------------------------------------------------------------------------
/data/config.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | -------------------------------------------------
4 | File Name: config
5 | Description :
6 | Author : vant
7 | date: 2021/5/26
8 | -------------------------------------------------
9 | Change Activity:
10 | 2022/5/09:
11 | -------------------------------------------------
12 | """
13 | __author__ = 'vant'
14 |
15 | import configparser
16 | import os
17 |
18 |
19 | class Config:
20 | def __init__(self):
21 | BASE_PATH = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
22 | CONFIG_FILE = os.path.join(BASE_PATH, 'data', 'config.ini')
23 | self.config = configparser.ConfigParser()
24 | self.config.read(CONFIG_FILE)
25 |
26 | def get(self, filename, key):
27 | conf = self.config.get(filename, key)
28 | return conf
29 |
30 | def path(self):
31 | BASE_PATH = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
32 | return BASE_PATH
33 |
34 |
35 | if __name__ == '__main__':
36 | c = Config()
37 | print(c.path())
38 | # print(c.get('browserType','browserName'))
39 |
--------------------------------------------------------------------------------
/drivers/IEDriverServer.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G2Bent/Vantpy/37369b8494b79ca60c99593fe3c75981035c8ec1/drivers/IEDriverServer.exe
--------------------------------------------------------------------------------
/drivers/chromedriver.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G2Bent/Vantpy/37369b8494b79ca60c99593fe3c75981035c8ec1/drivers/chromedriver.exe
--------------------------------------------------------------------------------
/drivers/phantomjs.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G2Bent/Vantpy/37369b8494b79ca60c99593fe3c75981035c8ec1/drivers/phantomjs.exe
--------------------------------------------------------------------------------
/report/HTMLTestRunner3.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | A TestRunner for use with the Python unit testing framework. It
4 | generates a HTML report to show the result at a glance.
5 |
6 | The simplest way to use this is to invoke its main method. E.g.
7 |
8 | import unittest
9 | import HTMLTestRunner
10 |
11 | ... define your tests ...
12 |
13 | if __name__ == '__main__':
14 | HTMLTestRunner.main()
15 |
16 |
17 | For more customization options, instantiates a HTMLTestRunner object.
18 | HTMLTestRunner is a counterpart to unittest's TextTestRunner. E.g.
19 |
20 | # output to a file
21 | fp = file('my_report.html', 'wb')
22 | runner = HTMLTestRunner.HTMLTestRunner(
23 | stream=fp,
24 | title='My unit test',
25 | description='This demonstrates the report output by HTMLTestRunner.'
26 | )
27 |
28 | # Use an external stylesheet.
29 | # See the Template_mixin class for more customizable options
30 | runner.STYLESHEET_TMPL = ''
31 |
32 | # run the test
33 | runner.run(my_test_suite)
34 |
35 |
36 | ------------------------------------------------------------------------
37 | Copyright (c) 2004-2007, Wai Yip Tung
38 | All rights reserved.
39 |
40 | Redistribution and use in source and binary forms, with or without
41 | modification, are permitted provided that the following conditions are
42 | met:
43 |
44 | * Redistributions of source code must retain the above copyright notice,
45 | this list of conditions and the following disclaimer.
46 | * Redistributions in binary form must reproduce the above copyright
47 | notice, this list of conditions and the following disclaimer in the
48 | documentation and/or other materials provided with the distribution.
49 | * Neither the name Wai Yip Tung nor the names of its contributors may be
50 | used to endorse or promote products derived from this software without
51 | specific prior written permission.
52 |
53 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
54 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
55 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
56 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
57 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
58 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
59 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
60 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
61 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
62 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
63 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 | """
65 |
66 | # URL: http://tungwaiyip.info/software/HTMLTestRunner.html
67 |
68 | __author__ = "Wai Yip Tung"
69 | __version__ = "0.9.1"
70 |
71 | """
72 | Change History
73 | Version 0.9.1
74 | * 用Echarts添加执行情况统计图 (灰蓝)
75 |
76 | Version 0.9.0
77 | * 改成Python 3.x (灰蓝)
78 |
79 | Version 0.8.3
80 | * 使用 Bootstrap稍加美化 (灰蓝)
81 | * 改为中文 (灰蓝)
82 |
83 | Version 0.8.2
84 | * Show output inline instead of popup window (Viorel Lupu).
85 |
86 | Version in 0.8.1
87 | * Validated XHTML (Wolfgang Borgert).
88 | * Added description of test classes and test cases.
89 |
90 | Version in 0.8.0
91 | * Define Template_mixin class for customization.
92 | * Workaround a IE 6 bug that it does not treat
205 |
206 |
207 |
301 |
302 |
303 | %(heading)s
304 | %(report)s
305 | %(ending)s
306 | %(chart_script)s
307 |
308 |
309 |