• 关于 UI 自动化的前途 at 2018年09月07日

    看了帮助很大啊,感谢大佬指导

  • 构建日志如下:

    由用户 jsx 启动
    构建中 在工作空间 /var/lib/jenkins/workspace/接口测试_maven 中
    Updating http://svn.91sph.com/svn/sph/server-service at revision '2018-08-15T16:54:34.100 +0800' --quiet
    Using sole credentials build/****** in realm ‘http://svn.91sph.com:80 VisualSVN Server’
    At revision 21847

    Using sole credentials build/****** in realm ‘http://svn.91sph.com:80 VisualSVN Server’
    No emails were triggered.
    [接口测试_maven] $ /bin/sh -xe /tmp/jenkins2568474232541011686.sh

    • convmv -f gbk -t utf-8 -r --notest /usr/jsx/apitest/src Skipping, already UTF-8: /usr/jsx/apitest/src/test/jmeter/查询书籍.jmx Ready! Script returned: Parsing POMs Established TCP socket on 46136 [apitest] $ /usr/jsx/jdk1.8.0_181/bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.12-alpha-1.jar:/usr/jsx/apache-maven-3.5.4/boot/plexus-classworlds-2.5.2.jar:/usr/jsx/apache-maven-3.5.4/conf/logging jenkins.maven3.agent.Maven35Main /usr/jsx/apache-maven-3.5.4 /var/cache/jenkins/war/WEB-INF/lib/remoting-3.23.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.12-alpha-1.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.12-alpha-1.jar 46136 <===[JENKINS REMOTING CAPACITY]===>channel started Executing Maven: -B -f /usr/jsx/apitest/pom.xml install [INFO] Scanning for projects... [INFO] [INFO] ----------------------------< jsx:apitest >----------------------------- [INFO] Building apitest 0.0.1-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ apitest --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /usr/jsx/apitest/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ apitest --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ apitest --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 3 resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ apitest --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ apitest --- [INFO] Surefire report directory: /usr/jsx/apitest/target/surefire-reports

    T E S T S

    Running jsx.apitest.AppTest
    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 sec

    Results :

    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

    [JENKINS] Recording test results
    [WARNING] Attempt to (de-) serialize anonymous class hudson.maven.reporters.SurefireArchiver$2; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
    [WARNING] Attempt to (de-) serialize anonymous class hudson.maven.reporters.BuildInfoRecorder$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
    [INFO]
    [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ apitest ---
    [INFO]
    [INFO] >>> jmeter-maven-plugin:2.1.0:jmeter (jmeter-tests) > :configure @ apitest >>>
    [INFO]
    [INFO] --- jmeter-maven-plugin:2.1.0:configure (configure) @ apitest ---
    [INFO] -------------------------------------------------------
    [INFO] Configuring JMeter...
    [INFO] -------------------------------------------------------
    [INFO]
    [INFO] <<< jmeter-maven-plugin:2.1.0:jmeter (jmeter-tests) < :configure @ apitest <<<
    [INFO]
    [INFO]
    [INFO] --- jmeter-maven-plugin:2.1.0:jmeter (jmeter-tests) @ apitest ---
    [INFO]

    [INFO] -------------------------------------------------------
    [INFO] P E R F O R M A N C E T E S T S
    [INFO] -------------------------------------------------------
    [INFO] Invalid value detected for . Setting pause to 0...
    [INFO]

    [INFO]

    [INFO] Executing test: 查询书籍.jmx
    [INFO] Writing log file to: /usr/jsx/apitest/target/jmeter/logs/查询书籍.jmx.log
    [INFO] Creating summariser


    [INFO] Created the tree successfully using /usr/jsx/apitest/target/jmeter/testFiles/查询书籍.jmx
    [INFO] Starting the test @ Wed Aug 15 16:56:00 CST 2018 (1534323360167)
    [INFO] Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
    [INFO] summary + 1 in 00:00:01 = 1.6/s Avg: 502 Min: 502 Max: 502 Err: 0 (0.00%) Active: 1 Started: 1 Finished: 0
    [INFO] summary + 2 in 00:00:00 = 28.2/s Avg: 31 Min: 29 Max: 33 Err: 2 (100.00%) Active: 0 Started: 1 Finished: 1
    [INFO] summary = 3 in 00:00:01 = 4.2/s Avg: 188 Min: 29 Max: 502 Err: 2 (66.67%)
    [INFO] Tidying up ... @ Wed Aug 15 16:56:00 CST 2018 (1534323360954)
    [INFO] ... end of run
    [INFO] Completed Test: 查询书籍.jmx
    [INFO]
    [INFO] --- xml-maven-plugin:1.0-beta-3:transform (default) @ apitest ---
    Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
    [INFO] Transforming file: /usr/jsx/apitest/target/jmeter/results/20180815-查询书籍.jtl
    [INFO] Transformed 1 file(s).
    Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
    [INFO] Transforming file: /usr/jsx/apitest/target/jmeter/results/20180815-查询书籍.jtl
    [INFO] Transformed 1 file(s).
    [INFO]
    [INFO] --- maven-install-plugin:2.4:install (default-install) @ apitest ---
    [INFO] Installing /usr/jsx/apitest/target/apitest-0.0.1-SNAPSHOT.jar to /var/lib/jenkins/.m2/repository/jsx/apitest/0.0.1-SNAPSHOT/apitest-0.0.1-SNAPSHOT.jar
    [INFO] Installing /usr/jsx/apitest/pom.xml to /var/lib/jenkins/.m2/repository/jsx/apitest/0.0.1-SNAPSHOT/apitest-0.0.1-SNAPSHOT.pom
    [WARNING] Attempt to (de-) serialize anonymous class hudson.maven.reporters.MavenArtifactArchiver$2; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
    [WARNING] Attempt to (de-) serialize anonymous class hudson.maven.reporters.MavenFingerprinter$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 9.608 s
    [INFO] Finished at: 2018-08-15T16:56:02+08:00
    [INFO] ------------------------------------------------------------------------
    Waiting for Jenkins to finish collecting data
    [JENKINS] Archiving /usr/jsx/apitest/pom.xml to jsx/apitest/0.0.1-SNAPSHOT/apitest-0.0.1-SNAPSHOT.pom
    [JENKINS] Archiving /usr/jsx/apitest/target/apitest-0.0.1-SNAPSHOT.jar to jsx/apitest/0.0.1-SNAPSHOT/apitest-0.0.1-SNAPSHOT.jar
    /usr/jsx/apitest/pom.xml is not inside /var/lib/jenkins/workspace/接口测试_maven/usr/jsx/apitest/; will archive in a separate pass
    /usr/jsx/apitest/target/apitest-0.0.1-SNAPSHOT.jar is not inside /var/lib/jenkins/workspace/接口测试_maven/usr/jsx/apitest/; will archive in a separate pass
    channel stopped
    [INFO] Shutdown detected, destroying JMeter process...
    [htmlpublisher] Archiving HTML reports...
    [htmlpublisher] Archiving at PROJECT level /usr/jsx/apitest/target/jmeter/html to /var/lib/jenkins/jobs/接口测试_maven/htmlreports/_e7bb9f_e8aea1_e68aa5_e5918a
    [htmlpublisher] Archiving at PROJECT level /usr/jsx/apitest/target/jmeter/html1 to /var/lib/jenkins/jobs/接口测试_maven/htmlreports/_e8afa6_e7bb86_e68aa5_e5918a
    Email was triggered for: Success
    Sending email for trigger: Success
    Sending email to: jinshengxun@91sph.com
    Finished: SUCCESS

  • 跟我现象一样,解决了吗?

  • 对,不懂 java 的业务测试人员用起来确实有难度,以后将转成 xml 形式或自定义语法的文本化脚本,同时引入脚本录制功能,尽量方便维护修改。

  • 链接是永久有效的,进入后如下:

    业主网络是不是有问题?以后代码共享在 git 上,更专业点

  • 我理解的是把 java 写的业务脚本转换为 xml 形式,方便用户以后修改是吗

  • 业务发生比那话无非要修改业务脚本、控件定位、测试输入数据 3 种,现在已经做到脚本/控件/数据的唯一性,哪个部分发生变化只修改一次即可。不知道业主说的 “自动或者选择拾取关键字,生成关键字对应的 xml” 啥意思?

  • 类似 qtp 的快速模式吧,以后打算把框架平台化,让用户直接在平台上写脚本,类似如下格式:
    输入 | 登录页.用户名输入框 |userid;
    输入 | 登录页.密码输入框 |password;
    点击 | 登录页.登录按钮;
    var1=获取 | 首页.右上角登录信息.用户名;
    var2=获取 | 首页.右上角登录信息.用户名 | 是否激活;
    支持页面操作和数据获取,同时引入循环和条件判断机制,这样任何复杂业务场景应该都能实现,效果跟我现在用 java 写脚本完全一样。

  • @testly
    2,同时上层框架化的话局限性挺大,让别人看到上层的东西会感觉技术 sense 有点 low
    答:确实 low 点😂 ,我本来就业务测试出身,对技术不是很敏感,之前想的是在自己的技术范围内只要满足自动化需求就 OK 了,不过考虑为了框架扩展必须使用标准技术,如项目改成 maven,数据存储用 xml/yml 之类,使用关键字驱动方式脱离 java 环境下脚本编写等。
    3,其次有一些复杂场景支持不是很好
    答:如果指的是复杂业务场景,我是用业务单元形式写脚本,测试用例全部通过这些业务单元实现脚本,这些业务单元通过参数驱动调用,实现脚本重复利用,任何复杂业务都可以实现且保证脚本和数据唯一性,可以参考下面的用例案例。

    整个用例先后经历 15 个业务单元完成脚本,在 4 个结果页面进行断言判断,算是业务比较复杂的用例。业务单元和测试用例框架提供了对应的实现机制,只要业务分析到位,觉得任何复杂用例都能快速编写脚本。

  • 有相关说明文档吗

  • 我的思路是:每个测试手机各自编写上传头像的脚本,调用时根据设备 udid 或设备名称定位是哪个手机,再调用对应的上传头像的脚本,虽然麻烦但可以考虑下。目前也没找到直接通用的办法。

  • appiumserver 启动多个,每个 server 用不同端口,每个手机通过端口分别关联到一个 appiumserver 同时 udid 设置为自己的设备编号,设备编号可以通过命令 adb devices 查看

  • Appium 报错后查错指南 at 2016年10月24日

    掌握 appium 很有帮助,支持!!!,必须收藏

  • 看来目前最简单的方式还是 2 楼提的建议,先打开 appium->设定等待操作->手动操作进入目标页面->执行脚本。谢谢大家指点。

  • #5 楼 @autotester ,执行 adb shell am start -S /这个命令,效果跟 driver.startActivity() 相同,都是从 app 的主页面开始进入,无法直接切换到中间页面

  • #6 楼 @seveniruby ,你是说 capabilities.setCapability()这个参数设置是吗?所有参数都看过,没有直接启动特定页面相关的参数,APPActivy 只能设定 launchableActivity。

  • #2 楼 @dongdong ,这个方法不错,让脚本等待到目标页面再执行

  • 有个疑问,能不能先手动移动到 app 的某个 activity 页面,然后启动 appium 捕获当前 activity 页面继续执行脚本?这个功能在调试脚本时很有用,无需从头开始执行。目前 driver.startActivity 只能重新打开 app,有没有办法实现以上想法?