51Testing软件测试论坛
标题:
在 robot framework 上封装 nodecv-server 的视觉判断关键字
[打印本页]
作者:
草帽路飞UU
时间:
2017-6-28 09:27
标题:
在 robot framework 上封装 nodecv-server 的视觉判断关键字
关键字封装
opencv连接接口服务
[Documentation] 根据API配置中接口服务器地址:${opencv_server_url} 连接接口服务
create session opencv ${opencv_server_url}
opencv关闭接口服务连接
[Documentation] 关闭所有服务
delete all sessions
opencv_dissimilarity
[Arguments] ${image1} ${image2}
[Documentation] 差异度 dissimilarity 的值 越小 差异 越小
... ${image1} ./image/macaca.png 图片名称只能使用字母数字及下划线
... ${image2} ./image/macaca_logo.png
${image1} _图片信息拼装 ${image1}
${image2} _图片信息拼装 ${image2}
${files} create dictionary image1=${image1} image2=${image2}
${addr} post request opencv ${POST_diss} files=${files}
should be equal as strings ${addr.status_code} 200
${responsedata} to json ${addr.content}
log ${responsedata}
[Return] ${responsedata}
opencv_matchtemplate
[Arguments] ${image1} ${image2}
[Documentation]
... ${image1} ./image/macaca.png 被匹配标记的大图
... ${image2} ./image/macaca_logo.png 为需要匹配的小图,
... 最好是颜色较深的 图片 带文字效果不好,获取小图在大图中的位置(坐标信息)
${image1} _图片信息拼装 ${image1}
${image2} _图片信息拼装 ${image2}
${files} create dictionary image1=${image1} image2=${image2}
${addr} post request opencv ${POST_match} files=${files}
should be equal as strings ${addr.status_code} 200
${responsedata} to json ${addr.content}
log ${responsedata}
[Return] ${responsedata}
opencv_cascadedetect
[Arguments] ${image1} ${image2}
[Documentation]
... ${image1} ./image/macaca.png
... ${image2} ./image/macaca_logo.png
${image1} _图片信息拼装 ${image1}
${image2} _图片信息拼装 ${image2}
# ${image1} evaluate ('image1', open('${image1}', 'rb'))
# ${image2} evaluate ('image2', open('${image2}', 'rb'))
${files} create dictionary image1=${image1} image2=${image2}
${addr} post request opencv ${POST_casca} files=${files}
should be equal as strings ${addr.status_code} 200
${responsedata} to json ${addr.content}
log ${responsedata}
[Return] ${responsedata}
opencv_findpairs
[Arguments] ${image1} ${image2}
[Documentation]
... ${image1} ./image/macaca.png 图片名称只能使用字母数字及下划线
... ${image2} ./image/macaca_logo.png
${image1} _图片信息拼装 ${image1}
${image2} _图片信息拼装 ${image2}
${files} create dictionary image1=${image1} image2=${image2}
${addr} post request opencv ${POST_findpairs} files=${files}
should be equal as strings ${addr.status_code} 200
${responsedata} to json ${addr.content}
log ${responsedata}
[Return] ${responsedata}
_图片信息拼装
[Arguments] ${image}
# ${i_name} get image name ${image}
# ${i_type} get image type ${i_name}
${i_name} evaluate re.search('\\w+\\.\\w+','${image}').group() re
${i_type} evaluate re.search('\\.\\w+','${i_name}').group() re
${i_type} Set Variable ${i_type[1:]}
${image} evaluate ('${i_name}', open('${image}', 'rb'), 'image/${i_type}', {'Expires': '0'})
[Return] ${image}
复制代码
关键字应用
8dol点击我的_微信登录
8dol_app_点击进入_登录引导页_微信登录
8dol_app_等待加载_微信登录页
sleep 1
${image} PK_8dol截屏 wechat_login
${responsedata} opencv_matchtemplate ${image} image/wechat_login.png
log ${responsedata}
${match} get from dictionary ${responsedata} match
${x_center} evaluate float(${match[1]})+float(${match[3]})/2
${y_center} evaluate float(${match[2]})+float(${match[4]})/2
PK_点击_坐标 ${x_center} ${y_center} #点击确认登录按钮
复制代码
作者:
乐哈哈yoyo
时间:
2017-6-28 15:42
我看到了“最好是”、“效果不好”
作者:
草帽路飞UU
时间:
2017-6-28 15:43
乐哈哈yoyo 发表于 2017-6-28 15:42
我看到了“最好是”、“效果不好”
呵呵 在我们app上用 效果 确实不太好!
不过还是有些场景可以用
在调用微信登录时, 正好用上
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2