Giter VIP home page Giter VIP logo

fautotest's Issues

是否可用提供端口和环境

微信小程序测试现在一直是在真机上,现在微信小程序开发越来越多,像这样一个基于WebDriver框架的python程序,来应用在真机上面进行测试,其实完全没有给出预期的解决方案。仅仅在真机上用WebDriver进行测试,绝大多数公司都能做,并不解决痛点。微信小程序测试要解决的痛点,是在微信账号和真机有限的情况下,如何部署数十甚至几十个微信小程序的自动化测试。
希望tx给出新的测试环境,类似于小程序开发者工具那种IDE,只不过这个环境是用于测试的,让微信小程序测试不必依赖微信,提供一个微信虚拟机环境,这样能够真实的解决小程序测试痛点。如果能在DockerHub上提供微信虚拟机环境的Docker,那就功德无量了。
而这个仓库所提供的FAutoTest,价值真的太低了。

h5Driver.isElementExist根据xpath获取元素,xpath expression 无效导致异常,api返回查找元素结果为True

代码部分,如下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}'
		}
	}
}

demo运行小程序的时候报错

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文件是怎么弄的

Mate 10 几个问题

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&parabcode=DZYH&openId=oWX3XjgdG3SWaFTos5oV0h5tDZ5c&k=ECSP&wechatOfficialAcct=wx1ec46f7d85a521b1&parabcode=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页面

H5demo报错

_fetchWebSocketDebugUrl
raise RuntimeError(errorMsg)
RuntimeError: 无法获取debug url,并检查是否配置了代理,是否已经建立了websocket连接未关闭

scrollWindow关键字,未支持传坐标(px)滑动

问题表现:

使用scrollWindow做滑动操作,传坐标值:scrollWindow(700,700,100,100,80),程序日志卡在scrollWindow处,小程序的表现为 自动退出小程序

用官方提供的关键字getWindowHeight getWindowWidth或得到屏幕的宽度、高度分别为612,,394(px/(dpi/160))的结果:
image
改滑动操作为scrollWindow(200,200,50,50,80) 即x,y值均在windowWidth windowHeight之内,滑动操作可以正常执行;

附上屏幕分辨率和dpi信息如下:

image

建议把 weixin.apk 放到其它地方,不要放在仓库中,会导致 clone 仓库的时候巨慢

建议把 /docs/assert/weixin663android1260.apk 这个 apk 独立出来放到一些在线云存储上去,不然 clone 仓库的时候可能会由于 git-lfs 导致速度很慢
我这边在本地 clone 的速度只有 20kb/s...
只不过放进去之后要再拿出来感觉会比较麻烦,而且这个 apk 还是和其它文件一起在 a0a065b 第一个 commit 提交上去的,有点难分离...

print() is a function and reload() is no longer a builtin in Python 3

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

小米手机无法获取进程ID问题及解决方案

image

问题在于这个adb命令获取的是MIUI桌面的activity 的PID

试了下 adb shell dumpsys activity top | findstr com.tencent.mm,可以拿到,可以考虑针对这种情况优化一下获取PID的策略

小程序底部菜单栏识别不到

小程序名字:小宇宙Heli
该小程序首页正常页面如下:
image
但是在chrome://inspect调试页面打开如下,发现底部的菜单栏显示不出来,试过另外几个页面,打开均空白。
image
请问是什么原因呢?应该要怎样解决?

执行H5demo报错找不到微信Tools进程,如何解决,也获取不到pid

执行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进程

可以增加支持企业微信么?

目前有项目在使用企业微信的开发,但是今天试了一下还不能支持企业微信,这个是因为企业微信本身的问题么?

运行damo报错

运行H5demo报错
websocket._exceptions.WebSocketConnectionClosedException: socket is already closed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.