tencent / fautotest Goto Github PK
View Code? Open in Web Editor NEWA UI automated testing framework for H5 and applets
License: Other
A UI automated testing framework for H5 and applets
License: Other
我看到有安装android sdk啥的,但是没看到ios相关的资料,是不能在ios版微信上进行测试吗?
什么时候支持py3?
from fastAutoTest.core.wx.wxEngine import WxDriver
import os
if name == 'main':
wxDriver = WxDriver()
wxDriver.initDriver()
# 点击全部疾病
wxDriver.clickElementByXpath('/html/body/div/div[1]/div[2]/div[1]/a')
wxDriver.clickFirstElementByText('肺癌')
wxDriver.returnLastPage()
wxDriver.returnLastPage()
# 截图
dirPath = os.path.split(os.path.realpath(__file__))[0]
PIC_SRC = os.path.join(dirPath, 'pic.png')
wxDriver.d.screenshot(PIC_SRC)
wxDriver.close()
上面是demo中运行小程序的代码,我连接了OPPO手机之后,先打开了腾讯医典,然后运行代码,但是报错如下:
Traceback (most recent call last):
File "C:/Users/charles/Downloads/FAutoTest-master/FAutoTest-master/sample/XcqDemo.py", line 17, in
wxDriver.initDriver()
File "C:\Users\charles\Downloads\FAutoTest-master\FAutoTest-master\fastAutoTest\core\wx\wxEngine.py", line 64, in initDriver
url = self._urlFetcher.fetchWebSocketDebugUrl()
File "C:\Users\charles\Downloads\FAutoTest-master\FAutoTest-master\fastAutoTest\core\wx\wxWebSocketDebugUrlFetcher.py", line 64, in fetchWebSocketDebugUrl
self._fetchInner()
File "C:\Users\charles\Downloads\FAutoTest-master\FAutoTest-master\fastAutoTest\core\wx\wxWebSocketDebugUrlFetcher.py", line 77, in _fetchInner
pid = WxWebSocketDebugUrlFetcher._fetchWeixinToolsProcessPid(device=self._device)
File "C:\Users\charles\Downloads\FAutoTest-master\FAutoTest-master\fastAutoTest\core\wx\wxWebSocketDebugUrlFetcher.py", line 100, in _fetchWeixinToolsProcessPid
raise RuntimeError(errorMsg)
RuntimeError: 获取小程序pid失败,请检查是否在小程序首屏进行初始化
我一段一段代码进行排查之后,发现wxWebSocketDebugUrlFetcher.py,这个文件中会在cmd中运行一串命令adb shell cat /proc/net/unix | findstr webview_devtools_remote_%s
而代码中是这么写的:
webviewCmd = _ADB_GET_WEBVIEW_TOOLS_CMD[osName] % (pid)
# 验证是否启动了小程序webview
try:
webStdout, webStdError = runCommand(AdbHelper.specifyDeviceOnCmd(webviewCmd, device))
print("--------"+webStdout)
except:
print("出错")
errorMsg = ErrorMsgManager().errorCodeToString(ERROR_CODE_NOT_ENTER_XCX)
raise RuntimeError(errorMsg)
return pid
也就是说运行这个命令错误,直接抛出异常的。
这个命令在你的INITERROR.md中并没有提到,我想问一下这个应该怎么解决呢?
能否不运行,直接把split得到的pid直接返回回去呢?
怎么样才能安装成功这个fauto,我这边不知道whl文件是怎么弄的
458 days until Python 2 end of life.
flake8 testing of https://github.com/Tencent/FAutoTest on Python 3.7.0
$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
./fastAutoTest/core/wx/wxEngine.py:32:1: F821 undefined name 'reload'
reload(sys)
^
./fastAutoTest/core/wx/wxWebSocketDebugUrlFetcher.py:270:34: E999 SyntaxError: invalid syntax
print webSocketUrl
^
./fastAutoTest/core/common/network/shortLiveWebSocket.py:108:40: E999 SyntaxError: invalid syntax
print 'already quit'
^
./fastAutoTest/core/h5/h5PageOperator.py:57:23: F821 undefined name 'unicode'
unicodeText = unicode(text, 'utf-8')
^
./fastAutoTest/core/h5/h5Engine.py:37:1: F821 undefined name 'reload'
reload(sys)
^
./fastAutoTest/core/qq/qqEngine.py:31:1: F821 undefined name 'reload'
reload(sys)
^
./fastAutoTest/utils/commandHelper.py:36:13: E999 SyntaxError: invalid syntax
print out
^
3 E999 SyntaxError: invalid syntax
4 F821 undefined name 'reload'
7
比如,输入 12345678901,实际输入后是12356789
建议把 /docs/assert/weixin663android1260.apk
这个 apk 独立出来放到一些在线云存储上去,不然 clone 仓库的时候可能会由于 git-lfs
导致速度很慢
我这边在本地 clone 的速度只有 20kb/s
...
只不过放进去之后要再拿出来感觉会比较麻烦,而且这个 apk 还是和其它文件一起在 a0a065b
第一个 commit 提交上去的,有点难分离...
1.每次运行脚本都会弹出安装uiautomator 和 uiautomator.test ,要怎么设置
2.下列脚本报错,要怎么修改?
from fastAutoTest.core.h5.h5Engine import H5Driver
import os
import time
'''
打开Android微信,利用ADB命令
'''
def openWechat():
os.system('adb shell am force-stop com.tencent.mm') # 杀掉微信
os.system('adb shell am start com.tencent.mm/.ui.LauncherUI') # 启动微信
time.sleep(15)
'''
H5页面操作
'''
def pageOperator(url,h5Driver):
h5Driver.navigateToPage(url)
#print("手机屏幕高度%s,手机屏幕宽带%s" % (h5Driver.getWindowHeight(),h5Driver.getWindowWidth()))
#print("H5页面CPU %s,内存信息%s" % (h5Driver.getCPUInfo(),h5Driver.getMemoryInfo()))
#while not h5Driver.isElementExist('.//*[text()="建寺功德"]'):
time.sleep(10)
h5Driver.returnLastPage()
def main_work():
openWechat()
h5Driver = H5Driver()
h5Driver.initDriver()
url = 'https://ecsp.icbc.com.cn/wechat_official_account/payWX/payIndex.html?code=0819ZC1b0GIlCv1FD11b0xEQ1b09ZC1V¶bcode=DZYH&openId=oWX3XjgdG3SWaFTos5oV0h5tDZ5c&k=ECSP&wechatOfficialAcct=wx1ec46f7d85a521b1¶bcode=DZYH&skinType=standard&code=0819ZC1b0GIlCv1FD11b0xEQ1b09ZC1V&state=icbc&token=oWX3XjgdG3SWaFTos5oV0h5tDZ5c'
pageOperator(url,h5Driver)
h5Driver.close()
if name == 'main':
main_work()
报错:
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.tencent.mm/.ui.LauncherUI }
Traceback (most recent call last):
File "", line 1, in
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/Users/kfzx-yanyj/Documents/PythonWorkSpace/FAutoTest/H5Test.py", line 35, in
main_work()
File "/Users/kfzx-yanyj/Documents/PythonWorkSpace/FAutoTest/H5Test.py", line 29, in main_work
h5Driver.initDriver()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/fastAutoTest/core/h5/h5Engine.py", line 63, in initDriver
url = self._urlFetcher.fetchWebSocketDebugUrl()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/fastAutoTest/core/h5/h5WebSocketDebugUrlFetcher.py", line 30, in fetchWebSocketDebugUrl
self._fetchInner()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/fastAutoTest/core/h5/h5WebSocketDebugUrlFetcher.py", line 48, in _fetchInner
self._webSocketDebugUrl = self._fetchWebSocketDebugUrl(self._localForwardPort)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/fastAutoTest/core/h5/h5WebSocketDebugUrlFetcher.py", line 155, in _fetchWebSocketDebugUrl
raise RuntimeError(errorMsg)
RuntimeError: 在执行脚本前,先进入H5页面
目前有项目在使用企业微信的开发,但是今天试了一下还不能支持企业微信,这个是因为企业微信本身的问题么?
代码部分,如下has_all_tab_cur 结果为true,实际看了日志才发现其实是没有找到元素的。
all_tab_xpath` = './/*[text()="所有订单"'
has_all_tab_cur = h5Driver.isElementExist(all_tab_xpath)
C:\Python27\Lib\site-packages\fastAutoTest\core\h5\h5Engine.py 方法 isElementExist 增加resultValueDict = self._networkHandler.send(getExistCmd).getResponse()[0]结果打印
resultValueDict = self._networkHandler.send(getExistCmd).getResponse()[0]
self.logger.debug("resultValueDict: {resultValueDict}".format(resultValueDict=resultValueDict))
resultType = resultValueDict['result']['result']['subtype']
num = 0
while resultType == 'null' and num < 3:
self.wait(WAIT_REFLESH_2_SECOND)
getExistCmd = self._pageOperator.isElementExist(xpath, contextId)
resultValueDict = self._networkHandler.send(getExistCmd).getResponse()[0]
resultType = resultValueDict['result']['result']['subtype']
num = num + 1
return resultType != 'null'
日志:
[2018-11-02 18:21:12,907] [pid:5688] [h5Engine.py:478] [isElementExist] DEBUG: resultValueDict: {u'result': {u'exceptionDetails': {u'columnNumber': 53, u'exception': {u'className': u'DOMException', u'subtype': u'error', u'type': u'object', u'description': u'DOMException: Failed to execute \'evaluate\' on \'Document\': The string \'.//*[text()="\u6240\u6709\u8ba2\u5355"\' is not a valid XPath expression.\n at <anonymous>:1:54', u'objectId': u'{"injectedScriptId":7,"id":2}'}, u'text': u'Uncaught', u'exceptionId': 1, u'scriptId': u'317', u'lineNumber': 0}, u'result': {u'className': u'DOMException', u'subtype': u'error', u'type': u'object', u'description': u'DOMException: Failed to execute \'evaluate\' on \'Document\': The string \'.//*[text()="\u6240\u6709\u8ba2\u5355"\' is not a valid XPath expression.\n at <anonymous>:1:54', u'objectId': u'{"injectedScriptId":7,"id":1}'}}}
True
分析:
resultValueDict 返回结果的json数据如下,其中 resultValueDict['result']['result']['subtype']值为‘error’。源码中只判断了resultType != 'null',导致返回结果为true。使用者在未打开日志的场景下,并不知道自己的xpath expression 是错误的,还以为是找到了元素,这对结果的判断是不准确的。
{
u 'result': {
u 'exceptionDetails': {
u 'columnNumber': 53,
u 'exception': {
u 'className': u 'DOMException',
u 'subtype': u 'error',
u 'type': u 'object',
u 'description': u 'DOMException: Failed to execute \'evaluate\' on \'Document\': The string \'.//*[text()="\u6240\u6709\u8ba2\u5355"\' is not a valid XPath expression.\n at <anonymous>:1:54',
u 'objectId': u '{"injectedScriptId":7,"id":2}'
},
u 'text': u 'Uncaught',
u 'exceptionId': 1,
u 'scriptId': u '317',
u 'lineNumber': 0
},
u 'result': {
u 'className': u 'DOMException',
u 'subtype': u 'error',
u 'type': u 'object',
u 'description': u 'DOMException: Failed to execute \'evaluate\' on \'Document\': The string \'.//*[text()="\u6240\u6709\u8ba2\u5355"\' is not a valid XPath expression.\n at <anonymous>:1:54',
u 'objectId': u '{"injectedScriptId":7,"id":1}'
}
}
}
锤子手机运行H5Demo脚本,卡死并且没有任何提示
_fetchWebSocketDebugUrl
raise RuntimeError(errorMsg)
RuntimeError: 无法获取debug url,并检查是否配置了代理,是否已经建立了websocket连接未关闭
1.未指明pip镜像地址,https://git.code.tencent.com/Tencent_Open_Source/FAutoTest
目前其他源暂时没有FAutoTest。建议备注下哈。对萌新不是很友好。。。
2.demo目前跑通了h5的,qq和小程序的还在尝试中。
最后更新时间1月24日,小程序都7.0版本了,很多组件都有更新,FAutoTest洗洗睡吧
执行H5Demo错误日志如下:
Error in sys.excepthook:
Traceback (most recent call last):
File "/Users/ios3rd/Desktop/Test/Tools/FAutoTest-master/fastAutoTest/utils/vmhook.py", line 48, in _handleUncaughtException
raise Exception(exctype)
Exception: <type 'exceptions.RuntimeError'>
Original exception was:
Traceback (most recent call last):
File "/Users/ios3rd/Desktop/Test/Tools/FAutoTest-master/sample/H5Demo.py", line 17, in
h5Driver.initDriver()
File "/Users/ios3rd/Desktop/Test/Tools/FAutoTest-master/fastAutoTest/core/h5/h5Engine.py", line 70, in initDriver
url = self._urlFetcher.fetchWebSocketDebugUrl()
File "/Users/ios3rd/Desktop/Test/Tools/FAutoTest-master/fastAutoTest/core/h5/h5WebSocketDebugUrlFetcher.py", line 37, in fetchWebSocketDebugUrl
self._fetchInner()
File "/Users/ios3rd/Desktop/Test/Tools/FAutoTest-master/fastAutoTest/core/h5/h5WebSocketDebugUrlFetcher.py", line 49, in _fetchInner
pid = H5WebSocketDebugUrlFetcher._fetchWeixinToolsProcessPid(device=self._device)
File "/Users/ios3rd/Desktop/Test/Tools/FAutoTest-master/fastAutoTest/core/h5/h5WebSocketDebugUrlFetcher.py", line 88, in _fetchWeixinToolsProcessPid
raise RuntimeError(errorMsg)
RuntimeError: 找不到微信Tools进程
微信小程序测试现在一直是在真机上,现在微信小程序开发越来越多,像这样一个基于WebDriver
框架的python
程序,来应用在真机上面进行测试,其实完全没有给出预期的解决方案。仅仅在真机上用WebDriver
进行测试,绝大多数公司都能做,并不解决痛点。微信小程序测试要解决的痛点,是在微信账号和真机有限的情况下,如何部署数十甚至几十个微信小程序的自动化测试。
希望tx给出新的测试环境,类似于小程序开发者工具那种IDE,只不过这个环境是用于测试的,让微信小程序测试不必依赖微信,提供一个微信虚拟机环境,这样能够真实的解决小程序测试痛点。如果能在DockerHub上提供微信虚拟机环境的Docker,那就功德无量了。
而这个仓库所提供的FAutoTest,价值真的太低了。
原生的组件没法定位,该如何进行action测试
这个框架可以测试哪些性能指标呢?求大神指教 万分感谢~~~~~
这个是更通用的方案:
https://github.com/richshaw2015/wxapp-appium
没有人来维护了吗?期待python3.7及以后版本
我看到有安装android sdk啥的,但是没看到ios相关的资料,是不能在ios版微信上进行测试吗?
运行H5 demo,报错socket.error: [Errno 10054]
运行H5demo报错
websocket._exceptions.WebSocketConnectionClosedException: socket is already closed.
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.