FAutoTest icon indicating copy to clipboard operation
FAutoTest copied to clipboard

Mate 10 几个问题

Open sillyjims opened this issue 6 years ago • 3 comments

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页面

sillyjims avatar Oct 14 '18 11:10 sillyjims

1.应该是手机权限问题,看看是不是设置了相关的权限。 2.从你报错的堆栈来看,应该是打开微信未使页面处于H5页面;在再执行H5引擎的相关的API时,应保证目前处于H5页面环境下,可随意进入某个H5页面,再执行 h5Driver.navigateToPage(url) 跳转到你指定的测试页面。

Chrisdimion avatar Oct 15 '18 03:10 Chrisdimion

1.应该是手机权限问题,看看是不是设置了相关的权限。 -----脚本运行时,会每次都安装uiautomator 和 uiautomator.test 2.从你报错的堆栈来看,应该是打开微信未使页面处于H5页面;在再执行H5引擎的相关的API时,应保证目前处于H5页面环境下,可随意进入某个H5页面,再执行 h5Driver.navigateToPage(url) 跳转到你指定的测试页面。 ---随意进入某个H5页面,这个动作通过FAutoTest自动化脚本怎么实现呢?打开微信后,默认时通信记录列表,没处于H5页面,而是不是此时的h5Driver不能初始化?

sillyjims avatar Oct 15 '18 07:10 sillyjims

1.应该是手机权限问题,看看是不是设置了相关的权限。 -----脚本运行时,会每次都安装uiautomator 和 uiautomator.test 2.从你报错的堆栈来看,应该是打开微信未使页面处于H5页面;在再执行H5引擎的相关的API时,应保证目前处于H5页面环境下,可随意进入某个H5页面,再执行 h5Driver.navigateToPage(url) 跳转到你指定的测试页面。 ---随意进入某个H5页面,这个动作通过FAutoTest自动化脚本怎么实现呢?打开微信后,默认时通信记录列表,没处于H5页面,而是不是此时的h5Driver不能初始化?

对于第二个问题。如何随意进入H5界面,可以通过uiautomator,进入任意公众号,然后进入任意文章,之后再执行init操作即可。

Jaggerer avatar Oct 15 '18 13:10 Jaggerer