GithubHelp home page GithubHelp logo

鲁工,请问是否有有一些命令行参数,可以脱离MTC的客户端,进行单独的录制和回放,在Ubuntu系统上使用,谢谢您! about cafe HOT 10 OPEN

baidu avatar baidu commented on August 16, 2024
鲁工,请问是否有有一些命令行参数,可以脱离MTC的客户端,进行单独的录制和回放,在Ubuntu系统上使用,谢谢您!

from cafe.

Comments (10)

luxiaoyu avatar luxiaoyu commented on August 16, 2024

可以脱离MTC客户端单独使用录制回放,客户端只是方便初级用户使用。
我自己有个ubuntu下的命令行脚本用于平时debug,由于需要Android4.2的源码编译环境,而且每次脚本都会编译Cafe,这里就不提供了。
简单的说,就是在测试工程中调用local.beginRecordCode();然后sleep,等待手工输入,输入结束后kill掉目标app即可;把录制好的java代码pull出来,扔到另一个测试工程中编译运行即可回放刚才的手工输入。
具体说,你可以按照如下步骤建立自己的录制回放工具

前提:需要安装Cafe.apk和先运行cafe_setup.sh

录制部分
1.把target apk用debug签名并安装
2.把https://github.com/BaiduQA/Cafe/blob/master/tests/TestRecord/src/com/example/demo/test/CafeReplay.java 放到一个干净的测试工程中;注意,代码中的LAUNCHER_ACTIVITY_FULL_CLASSNAME和TARGET_PACKAGE用实际target apk的包名等字符串描述替换原来的标识符。多说一句,这个测试工程需要引用cafe.jar。然后把测试工程编译成apk,用debug签名并安装
3.开一个窗口观察录制的情况,adb logcat -v time ViewRecorder:I RecorderCode:I LocalLib:I *:S
3.用$ADB shell am instrument -e class com.example.demo.test.CafeReplay#testRecorded -w $test_package/com.baidu.cafe.CafeTestRunner 运行录制apk,等到logcat打出"ViewRecorder is ready to work."即表示此时可以开始录制了。
4.想要停止录制时只需要ctrl-c掉命令行的adb shell am instrument即可,录制的结果可以这样取得:adb pull /data/data/$target_package/files/CafeReplay.java .

回放部分
1.把CafeReplay.java扔到另一个测试工程里,编译、安装、运行
2.测试报告和回放截图可以这样得到:adb pull /data/data/$target_package/files .

from cafe.

oatsuper avatar oatsuper commented on August 16, 2024

谢谢鲁工,我按照您的建议进行下尝试,真心感谢您的回复!
此外,我想问下针对录制回放的部分,针对/dev/input/eventX的事件类型结构体的拦截,再次写入相应的eventX中,这样感觉更底层的模拟传递android的输入事件!您之前没有考虑,是不是主要因为这样的录制和回放还是基于坐标类型,测试用例复用不好?
关于MTC的设备连接,确实需要加入adb connect的类型,现在的智能电视设备,没有相应的adb usb 连接了,呵呵

from cafe.

luxiaoyu avatar luxiaoyu commented on August 16, 2024

你说得对,因为基于坐标的录制回放虽然实现简单方便,但是无法适应分辨率的变化、不同版本安卓操作系统的变化,所以就选择了基于控件的录制回放,国外的一些录制回放工具也都是基于控件的
没搞过智能电视,不太清楚没有adb shell以后怎么测试,也许可以通过wifi连接adb?

from cafe.

oatsuper avatar oatsuper commented on August 16, 2024

是呀,确实需要再MTC的控件中,添加上wifi连接adb的设置选项,这样,对于智能电视的产品也可以连接使用了
此外,如果不仅仅针对某个apk,如果是立足于整个手机系统的应用的交互测试,您的测试框架适用么?

from cafe.

luxiaoyu avatar luxiaoyu commented on August 16, 2024

当初写Cafe的初衷就是为了实现系统级交互测试。。
比如,跨进程测试功能,即注入一个进程测试,在必要时唤起另一个app,分析并操作上面的UI元素。
不过,跨进程测试有场景限制,需要adb shell getprop ro.debuggable 为1,即debug版的android系统

from cafe.

luxiaoyu avatar luxiaoyu commented on August 16, 2024

对了,还有就是比如开关wifi这种操纵系统service的也支持,详见https://github.com/BaiduQA/Cafe/blob/master/testrunner/src/com/baidu/cafe/remote/IRemoteArms.aidl

from cafe.

zhyx avatar zhyx commented on August 16, 2024

@luxiaoyu:鲁工,请问想a应用通过startActivityForResult启动b应用再返回到a应用,或者a应用启动b应用这2类场景,cafe需要怎么设计?可以通过录制回放解决吗,谢谢!

from cafe.

luxiaoyu avatar luxiaoyu commented on August 16, 2024

这个a2b2a的case不适合用录制回放解决,需要手写,跨进程相关操作参见remote.clickxxx,要返回a的话remote.sendkey(back)返回就好

from cafe.

zhyx avatar zhyx commented on August 16, 2024

@luxiaoyu :鲁工,请问想直接修改xml文件,有没xml的说明文档规范,谢谢

from cafe.

luxiaoyu avatar luxiaoyu commented on August 16, 2024

@zhyx 照着Cafe的api改即可,xml编译时会生成java文件

from cafe.

Related Issues (20)

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.