Tonyzhangcanon / AUICrawler

Android App UI自动遍历方案(有时比较忙,没有进一步开发,欢迎大家积极沟通&贡献)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

git到本地,执行runner.py,直接退出

liwanyin opened this issue · comments

D:\Python27\python.exe G:/Python/AUICrawler/AUICrawler/runner/runner.py
Process finished with exit code 0

执行文件是 Crawler.py

在请问下执行Crawler.py也是报错,如下:
D:\Python27\python.exe G:/Python/AUICrawler/AUICrawler/Crawler.py
G:\Python\AUICrawler\AUICrawler/result/20170324182758
AUICrawler : 2017-03-24 18:27:59 Step : Init device : 32e2d1e17d63
AUICrawler : 2017-03-24 18:27:59 - id : 32e2d1e17d63
Traceback (most recent call last):
File "G:/Python/AUICrawler/AUICrawler/Crawler.py", line 10, in
plan = Plan()
File "G:\Python\AUICrawler\AUICrawler\module\PlanInfo.py", line 19, in init
self.deviceList = self.get_device_list()
File "G:\Python\AUICrawler\AUICrawler\module\PlanInfo.py", line 38, in get_device_list
device = Device(self, device_id)
File "G:\Python\AUICrawler\AUICrawler\module\DeviceInfo.py", line 18, in init
self.name = self.get_device_name()
File "G:\Python\AUICrawler\AUICrawler\module\DeviceInfo.py", line 71, in get_device_name
Saver.save_crawler_log(self.logPath, "device name : " + device_name)
UnboundLocalError: local variable 'device_name' referenced before assignment

Process finished with exit code 1

确保已经有Android设备连接
如果是Windows,修改DeviceInfo.py
line 64 : grep "product" ' -> findstr "product"
如果还报错,辛苦告诉我一下型号

后续我会解决一下这个环境问题,不用再修改代码,暂时还需要更改代码解决,还有几处linux 和 Windows执行命令的不同,可以搜索关键字 linux,注释中有标明命令的不同

已经提交了,只有两个执行方法有环境区分, 你有时间再试一下吧

好的 谢谢了!

可以执行了么?

拉起被测APK之后,界面一直没任何反应,Log如下,谢谢你的支持:

D:\Python27\python.exe G:/Python/AUICrawler/AUICrawler/Crawler.py
G:\Python\AUICrawler\AUICrawler/result/20170327151503
AUICrawler : 2017-03-27 15:15:08 Step : Init device : 32e2d1e17d63
AUICrawler : 2017-03-27 15:15:08 - id : 32e2d1e17d63
AUICrawler : 2017-03-27 15:15:08 - device name : Redmi 3S
AUICrawler : 2017-03-27 15:15:08 - device model : Redmi 3S

AUICrawler : 2017-03-27 15:15:08 - sys version : 6.0.1

AUICrawler : 2017-03-27 15:15:08 Step : get screen resolution
AUICrawler : 2017-03-27 15:15:09 - ['720', '1280']
AUICrawler : 2017-03-27 15:15:09 Step : creat screenshot folder
AUICrawler : 2017-03-27 15:15:09 Step : Update account : ['15210614522', '123456']
AUICrawler : 2017-03-27 15:15:09 - [<AUICrawler.module.DeviceInfo.Device instance at 0x0000000004531248>]
AUICrawler : 2017-03-27 15:15:09 Step : Init App ...
AUICrawler : 2017-03-27 15:15:09 - Apk Path : C:/Users/MD01/Downloads/EufyLife.apk
AUICrawler : 2017-03-27 15:15:09 - VersionCode : 1906
AUICrawler : 2017-03-27 15:15:09 - VersionName : 1.0.5
AUICrawler : 2017-03-27 15:15:09 - PackageName : com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:09 - LauncherActivity : com.oceanwing.smarthome.MainActivity
AUICrawler : 2017-03-27 15:15:09 - MainActivity : com.oceanwing.smarthome.MainActivity
AUICrawler : 2017-03-27 15:15:09 - LoginActivity : com.oceanwing.smarthome.MainActivity
AUICrawler : 2017-03-27 15:15:09 - Test Apk Path :
AUICrawler : 2017-03-27 15:15:09 - InitCaseList : ['com.dewmobile.kuaiya.test.cases.host.initcase.RunGuidePage']
AUICrawler : 2017-03-27 15:15:09 - FirstClickViews : ['com.oceanwing.smarthome:id/iv_transfer_to', 'com.oceanwing.smarthome:id/guide_i_know', 'com.oceanwing.smarthome:id/ok', 'com.oceanwing.smarthome:id/edit_ok', 'com.oceanwing.smarthome:id/button1', 'com.oceanwing.smarthome:id/iv_back']
AUICrawler : 2017-03-27 15:15:09 - BackBtnViews : ['com.oceanwing.smarthome:id/back', 'com.oceanwing.smarthome:id/iv_title_left', 'com.oceanwing.smarthome:id/back_iv', 'com.oceanwing.smarthome:id/iv_btn_back', 'com.oceanwing.smarthome:id/iv_back']
AUICrawler : 2017-03-27 15:15:09 - UnClickViews : ['com.oceanwing.smarthome:id/play_click', 'com.oceanwing.smarthome:id/fullscreen']
AUICrawler : 2017-03-27 15:15:09 - UnClickViews : ['com.oceanwing.smarthome:id/username', 'com.oceanwing.smarthome:id/password', 'com.oceanwing.smarthome:id/btn_login']
AUICrawler : 2017-03-27 15:15:09 - TestRunner : com.android.test.runner.MultiDexTestRunner
AUICrawler : 2017-03-27 15:15:09 Step : run test
AUICrawler : 2017-03-27 15:15:09 Step : run test
AUICrawler : 2017-03-27 15:15:09 Step : Update crawl statue from Inited to Running
AUICrawler : 2017-03-27 15:15:09 Step : clean device logcat cache
AUICrawler : 2017-03-27 15:15:09 Step : init application
AUICrawler : 2017-03-27 15:15:09 Step : init application
AUICrawler : 2017-03-27 15:15:09 Step : start up activity : com.oceanwing.smarthome.MainActivity
AUICrawler : 2017-03-27 15:15:10 Step : get top activity info
AUICrawler : 2017-03-27 15:15:10 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:10 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:11 Step : get top activity info
AUICrawler : 2017-03-27 15:15:12 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:12 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:12 Step : get top activity info
AUICrawler : 2017-03-27 15:15:12 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:12 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:13 Step : get top activity info
AUICrawler : 2017-03-27 15:15:14 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:14 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:14 Step : get top activity info
AUICrawler : 2017-03-27 15:15:15 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:15 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:16 Step : get top activity info
AUICrawler : 2017-03-27 15:15:16 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:16 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:17 Step : get top activity info
AUICrawler : 2017-03-27 15:15:17 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:17 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:18 Step : get top activity info
AUICrawler : 2017-03-27 15:15:18 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:18 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:19 Step : get top activity info
AUICrawler : 2017-03-27 15:15:19 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:19 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:23 Step : start up activity : com.facebook.react.devsupport.DevSettingsActivity
AUICrawler : 2017-03-27 15:15:23 Step : get top activity info
AUICrawler : 2017-03-27 15:15:24 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:24 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:24 Step : get top activity info
AUICrawler : 2017-03-27 15:15:24 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:24 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:25 Step : get top activity info
AUICrawler : 2017-03-27 15:15:25 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:25 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:26 Step : get top activity info
AUICrawler : 2017-03-27 15:15:26 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:26 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:27 Step : get top activity info
AUICrawler : 2017-03-27 15:15:27 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:27 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:28 Step : get top activity info
AUICrawler : 2017-03-27 15:15:28 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:28 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:29 Step : get top activity info
AUICrawler : 2017-03-27 15:15:29 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:29 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:29 Step : get top activity info
AUICrawler : 2017-03-27 15:15:29 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:29 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:30 Step : get top activity info
AUICrawler : 2017-03-27 15:15:30 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:30 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:31 Step : get top activity info
AUICrawler : 2017-03-27 15:15:31 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:31 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:32 Step : get top activity info
AUICrawler : 2017-03-27 15:15:32 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:32 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:33 Step : get top activity info
AUICrawler : 2017-03-27 15:15:33 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:33 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:36 Step : get top activity info
AUICrawler : 2017-03-27 15:15:36 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:36 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:36 Step : start up activity : com.oceanwing.smarthome.MainActivity
AUICrawler : 2017-03-27 15:15:37 Step : get top activity info
AUICrawler : 2017-03-27 15:15:37 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:37 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:38 Step : get top activity info
AUICrawler : 2017-03-27 15:15:38 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:38 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:39 Step : get top activity info
AUICrawler : 2017-03-27 15:15:39 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:39 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:40 Step : get top activity info
AUICrawler : 2017-03-27 15:15:40 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:40 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:41 Step : get top activity info
AUICrawler : 2017-03-27 15:15:41 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:41 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:42 Step : get top activity info
AUICrawler : 2017-03-27 15:15:42 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:42 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:43 Step : get top activity info
AUICrawler : 2017-03-27 15:15:43 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:43 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:44 Step : get top activity info
AUICrawler : 2017-03-27 15:15:44 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:44 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:45 Step : get top activity info
AUICrawler : 2017-03-27 15:15:45 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:45 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:49 Step : start up activity : com.google.android.gms.common.api.GoogleApiActivity
AUICrawler : 2017-03-27 15:15:50 Step : get top activity info
AUICrawler : 2017-03-27 15:15:50 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:50 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:51 Step : get top activity info
AUICrawler : 2017-03-27 15:15:51 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:51 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:52 Step : get top activity info
AUICrawler : 2017-03-27 15:15:52 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:52 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:52 Step : get top activity info
AUICrawler : 2017-03-27 15:15:52 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:52 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:53 Step : get top activity info
AUICrawler : 2017-03-27 15:15:53 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:53 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:54 Step : get top activity info
AUICrawler : 2017-03-27 15:15:54 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:54 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:55 Step : get top activity info
AUICrawler : 2017-03-27 15:15:55 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:55 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:56 Step : get top activity info
AUICrawler : 2017-03-27 15:15:56 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:56 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:56 Step : get top activity info
AUICrawler : 2017-03-27 15:15:57 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:57 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:57 Step : get top activity info
AUICrawler : 2017-03-27 15:15:57 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:57 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:58 Step : get top activity info
AUICrawler : 2017-03-27 15:15:58 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:58 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:15:59 Step : get top activity info
AUICrawler : 2017-03-27 15:15:59 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:15:59 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:16:02 Step : get top activity info
AUICrawler : 2017-03-27 15:16:02 - Top activity is :.MainActivity
AUICrawler : 2017-03-27 15:16:02 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-27 15:16:02 Step : remove uidunp xml
Exception in thread Thread-1:
Traceback (most recent call last):
File "D:\Python27\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "D:\Python27\lib\threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "G:\Python\AUICrawler\AUICrawler\runner\runner.py", line 1087, in run_test
remove_uidump_xml_file(device)
File "G:\Python\AUICrawler\AUICrawler\runner\runner.py", line 139, in remove_uidump_xml_file
os.remove(remove_xml_file)
WindowsError: [Error 2] : 'G:\Python\AUICrawler\AUICrawler/result/20170327151503/32e2d1e17d63/Uidump.xml'

Process finished with exit code 0

看了下Log,你设置的主页Activity:‘com.oceanwing.smarthome.MainActivity’, 而执行时获取的最上层的Activity : ‘.MainActivity’ ,不符,所以认为没有进入到主页,就一直没有执行
windows执行: adb shell dumpsys activity | grep "mResumedActivity
linux执行:adb shell dumpsys activity | findstr "mResumedActivity
看一下终端输出
嘿嘿,我都没想到会有人来试用,既然有人用了,也希望可以得到一些反馈,也可能会帮助反馈一些问题,从而改进的更好

也可以 将上述命令中的 “mResumedActivity” 改为 "mFocusedActivity" 看一下

好的,我有时间就在调试下

代码self.testPackageName = self.get_package_name(self.testApkPath)
Saver.save_crawler_log(plan.logPath, 'Test Apk PackageName : ' + self.testPackageName) 报错,如下

File "G:\Python\AUICrawler\AUICrawler\module\CrawledApp.py", line 39, in init
Saver.save_crawler_log(plan.logPath, 'Test Apk PackageName : ' + self.testPackageName)
TypeError: cannot concatenate 'str' and 'NoneType' objects

然后我把 Saver.save_crawler_log(plan.logPath, 'Test Apk PackageName : ' + self.testPackageName) 屏蔽了,能拉起测试APK但不执行,按照你上面说的改为 "mFocusedActivity" 仍一样

1.第一个报错应该是你没有Robotium的测试Apk,没有获取到包名,然后未空了,我稍后改一下,你先屏蔽掉吧
2.不执行:你先启动App,然后在终端执行 “adb shell dumpsys activity | grep "mResumedActivity”,
或者“adb shell dumpsys activity | grep "mFocusedActivity”,看一下结果显示的包名/后面是“com.oceanwing.smarthome.MainActivity”还是“.MainActivity”,如果是.MainActivity,修改下你设置的主页Activity就好了,要是其他的,那可能是我方法的问题,告诉我结果,我就会再修改
辛苦了

你可以把终端执行结果贴到这里,我看一下应该就知道原因了

mFocusedActivity: ActivityRecord{e993981 u0 com.oceanwing.smarthome/.MainActivity t902}

那你就直接将Setting.py 中的 AppMainActivity ,设置成“.MainActivity”吧,可能你们的App就是这样定义Activity的

改了之后,还是没反应,然后就退出了:
AUICrawler : 2017-03-28 11:07:39 Step : Init App ...
AUICrawler : 2017-03-28 11:07:39 - Apk Path : C:/Users/MD01/Downloads/EufyLife.apk
AUICrawler : 2017-03-28 11:07:39 - VersionCode : 1906
AUICrawler : 2017-03-28 11:07:39 - VersionName : 1.0.5
AUICrawler : 2017-03-28 11:07:39 - PackageName : com.oceanwing.smarthome
AUICrawler : 2017-03-28 11:07:39 - LauncherActivity : com.oceanwing.smarthome.MainActivity
AUICrawler : 2017-03-28 11:07:39 - MainActivity : .MainActivity
AUICrawler : 2017-03-28 11:07:39 - LoginActivity : .MainActivity
AUICrawler : 2017-03-28 11:07:39 - Test Apk Path :
AUICrawler : 2017-03-28 11:07:39 - InitCaseList : ['']
AUICrawler : 2017-03-28 11:07:39 - FirstClickViews : ['com.oceanwing.smarthome:id/iv_transfer_to', 'com.oceanwing.smarthome:id/guide_i_know', 'com.oceanwing.smarthome:id/ok', 'com.oceanwing.smarthome:id/edit_ok', 'com.oceanwing.smarthome:id/button1', 'com.oceanwing.smarthome:id/iv_back']
AUICrawler : 2017-03-28 11:07:39 - BackBtnViews : ['com.oceanwing.smarthome:id/back', 'com.oceanwing.smarthome:id/iv_title_left', 'com.oceanwing.smarthome:id/back_iv', 'com.oceanwing.smarthome:id/iv_btn_back', 'com.oceanwing.smarthome:id/iv_back']
AUICrawler : 2017-03-28 11:07:39 - UnClickViews : ['com.oceanwing.smarthome:id/play_click', 'com.oceanwing.smarthome:id/fullscreen']
AUICrawler : 2017-03-28 11:07:39 - UnClickViews : ['com.oceanwing.smarthome:id/username', 'com.oceanwing.smarthome:id/password', 'com.oceanwing.smarthome:id/btn_login']
AUICrawler : 2017-03-28 11:07:39 - TestRunner : com.android.test.runner.MultiDexTestRunner
AUICrawler : 2017-03-28 11:07:39 Step : Init device : 32e2d1e17d63
AUICrawler : 2017-03-28 11:07:39 - id : 32e2d1e17d63
AUICrawler : 2017-03-28 11:07:39 - device name :
AUICrawler : 2017-03-28 11:07:39 - device model : Redmi 3S

AUICrawler : 2017-03-28 11:07:39 - sys version : 6.0.1

AUICrawler : 2017-03-28 11:07:39 Step : get screen resolution
AUICrawler : 2017-03-28 11:07:40 - ['720', '1280']
AUICrawler : 2017-03-28 11:07:40 Step : creat screenshot folder
AUICrawler : 2017-03-28 11:07:40 Step : Update account : ['15210614522', '123456']
AUICrawler : 2017-03-28 11:07:40 - [<module.DeviceInfo.Device instance at 0x00000000042E0BC8>]
AUICrawler : 2017-03-28 11:07:40 Step : run test
AUICrawler : 2017-03-28 11:07:40 Step : run test
AUICrawler : 2017-03-28 11:07:40 Step : Update crawl statue from Inited to Running
AUICrawler : 2017-03-28 11:07:40 Step : clean device logcat cache
AUICrawler : 2017-03-28 11:07:40 Step : init application
AUICrawler : 2017-03-28 11:07:40 Step : init application
AUICrawler : 2017-03-28 11:07:40 Step : begin to crawl main nodes
AUICrawler : 2017-03-28 11:07:40 Step : begin to crawl main nodes
AUICrawler : 2017-03-28 11:07:40 Step : start up activity : .MainActivity
AUICrawler : 2017-03-28 11:07:41 Step : get top activity info
AUICrawler : 2017-03-28 11:07:42 - Top activity is :.MainActivity
AUICrawler : 2017-03-28 11:07:42 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-28 11:07:47 - get all nodes in this page
AUICrawler : 2017-03-28 11:07:49 - 59
AUICrawler : 2017-03-28 11:07:49 Step : get top activity info
AUICrawler : 2017-03-28 11:07:49 - Top activity is :.MainActivity
AUICrawler : 2017-03-28 11:07:49 - Top package is :com.oceanwing.smarthome
AUICrawler : 2017-03-28 11:07:49 Step : check page is crawlable or not
AUICrawler : 2017-03-28 11:07:49 - page is not crawlable
AUICrawler : 2017-03-28 11:07:49 Step : remove uidunp xml
AUICrawler : 2017-03-28 11:07:49 Step : 32e2d1e17d63 has Crawled 0 nodes.
AUICrawler : 2017-03-28 11:07:49 Step : 32e2d1e17d63 has Crawled 0 nodes.
AUICrawler : 2017-03-28 11:07:49 Step : 32e2d1e17d63 there are 0 unCrawled nodes .
AUICrawler : 2017-03-28 11:07:49 Step : 32e2d1e17d63 there are 0 unCrawled nodes .
AUICrawler : 2017-03-28 11:07:49 Step : 32e2d1e17d63 has Crawled 0 activities .
AUICrawler : 2017-03-28 11:07:49 Step : 32e2d1e17d63 has Crawled 0 activities .
AUICrawler : 2017-03-28 11:07:49 Step : Update crawl statue from Running to Passed

Process finished with exit code 0

使用的是最新的代码嘛,之前有一个版本有错误,会导致这个问题,是代码判断错了,然后就不执行,直接结束

代码是我早晨git下来的,看了下是最新的

有线上的Release包可以下载到嘛,看log,应该是获取到了主页上的控件,但是这个页面被判断成不可以遍历,没有有效的可遍历控件

我昨天有遍历过,所以应该代码上没有太大问题对于我们自己的App,但是你遇到的这个问题的原因,还是得再有App的情况下,我去分析原因

方便的话+我QQ吧,553410327

@Tonyzhangcanon 建议做下兼容,通过“adb shell dumpsys activity | grep "mResumedActivity”获取到的结果,会省略掉包名,可以用“adb shell dumpsys window w | grep / | grep name=”试试,综合一下

@gb112211 好的,我改一下,谢谢建议。欢迎更多的反馈,嘿嘿

@gb112211 是这样的,我对比了一下两种命令的输出

“adb shell dumpsys activity | grep "mResumedActivity”:>
mResumedActivity: ActivityRecord{37180b1f u0 com.miui.home/.launcher.Launcher t202}
“adb shell dumpsys window w | grep / | grep name=”:
mSurface=Surface(name=com.miui.home/com.miui.home.launcher.Launcher)

区别确实是在.launcher.Launcher前一个有包名,一个没有包名,
但是同样的我也对比了一下logcat中的输出,是没有包名的结果
u0 com.miui.home/.launcher.Launcher
此方法是用来获取最上层的Activity

  • 在遍历刚开始阶段用来判断是否到了Setting中设置的MainActivity

  • 在遍历过程中判断是否到了LoginActivity

  • 在Activity遍历模式中,判断是否在被遍历的Activity页面
    我是想,如果大家是通过查看log而设置的对应的Activity,那么执行应该是没有问题的吧
    不知道你提出的这个兼容的建议,是不是为了解决如果有人设置了带包名的activity,而不能正确执行的现象呢,还是有其他的原因

@Tonyzhangcanon 其实意思就是使用者设置的MainActivity,不管是前面带了包名,还是省略了包名,应该都处理为带包名的完整的Activity名称。使用者可能会通过Log去取MainActivity,也可能通过manifest文件里面去取MainActivity,前者取的会省略包名,后者的话就会带上包名了。

@gb112211
嗯,是的,如果使用这设置的MainActivity和脚本获取到的不同的话,确实会导致一些问题,是应该想办法兼容/解决一下。
但是,也许是我们公司的App特殊的原因?
adb shell dumpsys activity | grep "mResumedActivity”
adb shell dumpsys window w | grep / | grep name=

  • 两种方式获得的结果是相同的

  • 并且重点是,获取到的Activity并不是 “包名”.xxx.xxxactivity ,这就尴尬了...

所以如果优化的话,可能并不是在获取上层Activity这个方法上,也许应该是在后续的判断中,我们公司的App 通过aapt 分析manifest的话,获取到的activity名称也确实不是 “包名”.xxx.xxxactivity....
我再想一想