Sweetest 已全面升级为 Sweet,请访问:
GitHub:https://github.com/sweeterio
小而美的自动化测试解决方案,支持 Web UI 测试,Http 接口测试,DB 操作测试,App 测试,小程序测试,Windows GUI 测试,文件操作
Home Page: https://sweeter.io
Sweetest 已全面升级为 Sweet,请访问:
GitHub:https://github.com/sweeterio
元素需要div滚动条时可见,没有自动判断该滚动条滚动到元素可见位置
web测试中文件上传是基于window下的python包pypiwin32实现的,有实现mac文件上传的计划吗?
《Notepad-TestCase.xlsx》第6行测试数据把“value”错写成了“vaule”,造成运行报错。
response json: [{'id': 1981, 'icon': 'test1', 'name': 'test1', 'directDeviceGroupId': '1', 'status': None, 'count': 0}, {'id': 1980, 'icon': 'test', 'name': 'test', 'directDeviceGroupId': '1', 'status': None, 'count': 0}]
[
{
'id': 1981,
'icon': 'test1',
'name': 'test1',
'directDeviceGroupId': '1',
'status': None,
'count': 0
},
{
'id': 1980,
'icon': 'test',
'name': 'test',
'directDeviceGroupId': '1',
'status': None,
'count': 0
}
]
做接口测试,需要验证数据库的数据,用例表格要怎么写,能加个示例吗?
在 keywords / http.py
文件中增加:
增加了关键字form
用于POST方法 multipart/form-data提交数据方式的上传接口,在testcase中测试数据字段可书写为:
form={r'./files/test.xls': 'application/vnd.ms-excel'}
form={r'./files/test.zip': 'application/zip}
elif kw == 'post':
if 'form' in data:
form_dict = json2dict(data['form'])
try:
if len(form_dict) == 1:
for form_k, form_v in form_dict.items():
form_name = form_k.split("/")[-1]
form_data = MultipartEncoder(fields={'file': (form_name, open(form_k, 'rb'), form_v)})
form_headers = {'Content-Type': form_data.content_type}
http.r.headers.update(form_headers)
r = getattr(http.r, kw)(http.baseurl + url, data=form_data, timeout=timeout)
except:
logger.exception("***form can be only one Key-value***")
else:
r = getattr(http.r, kw)(http.baseurl + url,
data=_data['data'], json=_data['json'], files=_data['files'], timeout=timeout, **data)
logger.info(f'BODY: {r.request.body}')
增加了关键字binary
用于PUT方法二进制流的提交方式上传接口,在testcase中测试数据字段可书写为:
binary={r'./data/2209.jpg':'image/jpeg'}
elif kw in ('put', 'patch'):
if 'binary' in data:
binary_dict = json2dict(data['binary'])
try:
if len(binary_dict) == 1:
for binary_k, binary_v in binary_dict.items():
binary_headers = {'Content-Type': binary_v}
http.r.headers.update(binary_headers)
with open(binary_k, 'rb') as binary_f:
r = getattr(http.r, kw)(http.baseurl + url, data=binary_f, timeout=timeout)
except:
logger.exception("*** binary can be only one Key-value***")
else:
r = getattr(http.r, kw)(http.baseurl + url,
data=_data['data'], timeout=timeout, **data)
logger.info(f'BODY: {r.request.body}')
elif kw in ('delete', 'options'):
注册时,手机号码是唯一的,自己写了一个生成未注册手机号码的方法,写注册功能的用例时,能否直接调用这个生成手机号码的方法,将其生成的手机号码做为测试输入数据?
我想在“输出数据”列中,取到如下返回json数据的json[‘data’][1][‘id’]的ID数据,具体的取值代码要怎么写呢。
{
"code": 200,
"desc": null,
"data": [
{
"id": "afd3adcb320aeb3867d319196ba41b24",
"parentId": null,
"permissionCode": "PRODUCT_MANAGER",
"permissionUrl": "/",
"permissionName": "产品管理",
"permissionType": "menu",
"sort": 1,
"icon": null,
"tenantId": null,
"orgId": null,
"roleOwner": null,
"childs": null
},
{
"id": "c9a3a1588c18230ec6d5f01aa44d81c0",
"parentId": null,
"permissionCode": "FOR_TEST",
"permissionUrl": "/",
"permissionName": "主菜单",
"permissionType": "menu",
"sort": 1,
"icon": null,
"tenantId": null,
"orgId": null,
"roleOwner": null,
"childs": null
},
测试数据
一栏写入:json={"account":"\<\>","password":"test123",},,
BODY: b'{"account": "dsfw4rwfdfstg433dsdtgsgt43trfdf", "password": "test123"}'
在utility.py
文件中
def replace(data):
......
......
data = data.replace(r'\<', left_angle).replace(r'\>', right_angle)
......
......
# 正则匹配出 data 中所有 <> 中的变量,返回列表
keys = re.findall(r'%s' %(left_delimiter+'(.*?)'+right_delimiter), data)
_vars = {}
for k in keys:
......
......
return data
上述代码在执行此次用例在解析测试数据一栏时,keys匹配出来的内容为空,导致函数不进入for循环,而直接返回data。此时data已经被left_angle 和 right_angle 的字符串替换。
注意:如果测试数据
一栏中包含正常的变量值,则能进入for循环,"\<" 就能被正常转义成 <
根据以上情况,是否可以在代码中增加对keys的判断,如果为空,则执行一次data = data.replace(left_angle, '<').replace(right_angle, '>')
将字符串再替换回"<"和">"
安装后运行即报错
Android APP测试有相关说明文档吗
报错如下:
=== RESTART: F:\sweetest\sweetest-master\example\sweetest_example\start.py ===
Traceback (most recent call last):
File "F:\sweetest\sweetest-master\example\sweetest_example\start.py", line 24, in
sweet = Autotest(project_name, sheet_name, desired_caps, server_url)
File "C:\Users\yangbo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sweetest\autotest.py", line 39, in init
self.testcase_workbook = Excel(self.testcase_file, 'r')
File "C:\Users\yangbo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sweetest\utility.py", line 16, in init
self.workbook = xlrd.open_workbook(file_name)
File "C:\Users\yangbo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\xlrd_init_.py", line 122, in open_workbook
zf = zipfile.ZipFile(filename)
File "C:\Users\yangbo\AppData\Local\Programs\Python\Python36-32\lib\zipfile.py", line 1100, in init
self._RealGetContents()
File "C:\Users\yangbo\AppData\Local\Programs\Python\Python36-32\lib\zipfile.py", line 1163, in _RealGetContents
endrec = _EndRecData(fp)
File "C:\Users\yangbo\AppData\Local\Programs\Python\Python36-32\lib\zipfile.py", line 241, in _EndRecData
fpin.seek(0, 2)
AttributeError: 'WindowsPath' object has no attribute 'seek'
https://github.com/tonglei100/sweetest/blob/master/sweetest/sweetest/keywords/web.py#L171
看到封装了很多方法,但如果想拓展这些方法,lib文件夹的自定义函数可以支持么?
如果要支持click_and_hold和release应该要怎么操作
如:一共运行了多少用例,总共运行时间,成功的有多少个,失败的有多少个,平均用例执行时间,最长用例执行时间等等。
不支持双击操作
line 4, in <module>
from injson import check
'injson' module from where?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.