飞道的博客

CST全国大学生软件测试大赛参赛记录分享

832人阅读  评论(0)

2020年2月10日更新:

零基础的同学建议看一下这一篇:移动应用测试脚本编写案例Demo


2019年11月6日更新:

【题目下载】2019年CST全国大学生软件测试大赛试题下载,持续更新。

【超详细】全国大学生软件测试大赛:移动应用测试脚本编写要求

【超详细】全国大学生软件测试大赛:移动应用测试参赛指南


前几天去南京参加了全国大学生软件测试大赛的总决赛,这里把参赛过程记录一下。

全国大学生软件测试大赛第一届是2016年,到今年是举办的第三届了,是由南京大学陈振宇教授主持举办的。我大学的院长是从事软件测试方向的,所以和组织我们参加了第一届的比赛。

目录

2016年第一届

2017年第二届

分区决赛

总决赛

2018第三届

秋季预选赛

省赛

总决赛

脚本题

众包题


 

2016年第一届

当时学校刚开了软件测试的课程,可以说是比较少的开这门课的大学之一。当时也只是学学软件测试的概念,然后就是学学LoadRunner,并没有引起我的重视,LoadRunner也学得一般般。

后来老师通知让全部报名这个比赛,我就随着报上了....

2016年是第一届,难度也很小,但是对于毫无基础的我来说还是丈二和尚摸不着头脑,当然老师也是。由于我学校参加的学生较多,南京主办方那边专门派人过来给我们做了下培训,主要就是讲解一下比赛步骤、如何做题等等。

第一届时只有开发者测试、移动应用测试和嵌入式测试三个分赛项,我就报了开发者和移动测试,然后就把这事忘了....直到后来老师说上节课我们在慕测平台上做的题就是省赛的题目....emmm....后来就直接把证书发下来了,移动测试的省赛二等奖...然后有三个同学进入了决赛,老师带着三个人飞南京去参加决赛,机票主办方给报销,对于我一个没去过南京的小土鳖来说免费游南京这不错啊,后悔自己没能进决赛,然后就报名了第二届的比赛。

2017年第二届

第二年我就比较重视这个比赛了(毕竟想着免费游南京),上半年在老师的组织下就早早地报了名。

CST在预选赛前有资格赛,这个资格赛只要有分数即可获得参加预选赛的资格,可能是主办方让同学来熟悉环境的。预选赛分为夏季预选赛和秋季预选赛,通过任意一个即可进入省赛,省赛一等奖的可以直接得到总决赛资格,其余的参加全国的排名然后确定总决赛资格。

第一年基本没当回事,所以也没积累下什么经验,第二年也还是摸着石头过河,报了移动测试的个人赛和团队赛。很快就到了夏季预选赛的比赛时间,当时老师把大家组织到一个机房就开始做题,个人赛是两个脚本题,每个题100分,总分200。当时第一题提交后85分,做第二题时最后没时间了没能提交上,所以第二题得了0分(所以要提醒大家一定要边做边提交,不要把积攒到最后一块提交,当时候光改bug的时间都不够)。没想到就85分也进入了分赛区的决赛,而且排名还挺靠前,所以可以看出大家的水平都一般般。

分区决赛

2017年将省赛改成了区域赛,我参加的也就是华北赛区的决赛。华北赛区决赛比赛地点在山东大学,10月20多号具体时间忘了,老师带着我们同学来到山大,然后得知竟然在自习室里比赛,是的你没看错,不是专门的比赛教室,也不是机房,是自习室!主办方和华北赛区的赞助商到教室后和上自习的同学说明情况让后给我们扯了几个插排,让我们连上wifi....比赛开始了。来比赛的两个清华的大佬是真的强,一个第一名一个第二名。

2017年的比赛明显比2016年大了很多,分赛区也有奖金,一等奖是1000,二等奖是800,三等奖是600,好像是这个数目,具体的记不太清了。

分区决赛(团队赛)题目:

  • 考试名称:2017移动应用测试分区决赛(团队)已结束

  • 起止时间:2017-10-21 14:00   -   2017-10-21 18:00

  • 平台:慕测平台

  • 考试描述:

    本分项赛所有分区均为非现场赛。比赛说明: 第一题 Leafpic:在慕测平台的Eclipse客户端或虚拟机上完成Appium测试脚本; 第二题 中江智慧工地:在慕测平台完成众包测试报告。

  • 试卷名称分区决赛—移动应用测试(团体)-副本

  • 出卷人大赛组委会

  • 总分7

  • 难度:※※※※※
  •   题目名称 分值占比 得分规则 分数
     

    1.Leafpic 已提交

     APK

     需求文档

     脚本模板

    • 试题描述详情请看需求文档以及脚本编写要求。建议使用雷电虚拟机,安卓版本5.0以上
    50%
    manual 100%  
    暂无
     

    2.中江智慧工地 已提交我的报告

     APK

     需求文档

    • 试题描述详情请看需求文档
    50%
    manual 100%  
    暂无

总决赛

2017年11月27日向南京进发,不过今年没有了免费机票,不过有学校报销高铁票和酒店的费用也不错(ˇ?ˇ) 。

北方人第一次到南方,第一次见到长江

决赛签到地点在南京大学鼓楼校区的费彝民楼前

晚上顺便逛了一圈夫子庙,感受了一下“夜泊秦淮近酒家”。

28号的上午,就是移动应用测试的个人赛,个人赛有两个题目,一个脚本,一个众包。

第一个脚本题是“去哪儿APP”,测试点不多,难度不高,但是对于没大有经验的我来说也比较难了,很多按钮通过XPath去点击第一次运行和第二次运行的时候点击的地方不一样,导致运行的时候不得不把过不去的地方的代码删掉,最后多少分忘记了。

第二题众包,是一款报名学车的app(具体名称不提了),难度也不大,毕竟是个人赛。

总分100,第一题和第二题各占50%,然后第二题测试用例和BUG又各占50%,最后两个题一共得了 52分,并不高,只排第14名,二等奖。前两名毫无疑问还是那两个清华大佬。

28号的下午,是移动应用测试的团队赛,29号的上午,被选中参加了移动应用的人机大战,这里不详细写了。(团队赛的题目却是有难度)

再就是吐槽一点,2017年时测试用例和bug评分标准很不透明,尤其是团队赛,几个队伍几百个用例,下午比完赛晚上就评完了分,基本上就是按用例和bug数量去评分,被很多人吐槽不公平。

28号下午在南京大学鼓楼校区的大礼堂举行了颁奖典礼。

2018第三届

今年参加秋季预选赛的时候,已经来到了新的学校。

秋季预选赛带着班里另一个同学一块参加的,这同学之前也和我一个学校,不过并没有参加过这个比赛。

秋季预选赛

10月27号和28号是秋季预选赛的时间,今年依旧是移动应用测试,预选赛还是像之前那么的容易,两个APP,第一题77.61分,第二题54.50分,虽然进入了省赛,但是这个分不高,下面我把分数比较高的脚本放一下:


  
  1. /*
  2. *
  3. * 第一题:
  4. * 云阅APP
  5. * CloudRead
  6. *
  7. */
  8. package com.mooctest;
  9. import io.appium.java_client.AppiumDriver;
  10. import io.appium.java_client.AndroidKeyCode;
  11. import java.io.File;
  12. import java.net.MalformedURLException;
  13. import java.net.URL;
  14. import java.util.List;
  15. import java.util.concurrent.TimeUnit;
  16. import org.openqa.selenium.By;
  17. import org.openqa.selenium.NoSuchElementException;
  18. import org.openqa.selenium.WebElement;
  19. import org.openqa.selenium.remote.CapabilityType;
  20. import org.openqa.selenium.remote.DesiredCapabilities;
  21. import org.openqa.selenium.remote.UnreachableBrowserException;
  22. public class Main {
  23. /**
  24. * 所有和AppiumDriver相关的操作都必须写在该函数中
  25. * @param driver
  26. */
  27. public void test(AppiumDriver driver) {
  28. try {
  29. Thread.sleep( 6000); //等待6s,待应用完全启动
  30. } catch (InterruptedException e) {
  31. // TODO Auto-generated catch block
  32. e.printStackTrace();
  33. }
  34. driver.manage().timeouts().implicitlyWait( 8, TimeUnit.SECONDS); //设置尝试定位控件的最长时间为8s,也就是最多尝试8s
  35. /*
  36. * 余下的测试逻辑请按照题目要求进行编写
  37. */
  38. try {
  39. driver.findElementByXPath( "//android.widget.Button[@text='取消']").click();
  40. driver.findElementById( "com.example.jingbin.cloudreader:id/iv_title_one").click();
  41. driver.findElementByXPath( "//android.widget.TextView[@text='玩安卓']").click();
  42. driver.findElementsById( "com.example.jingbin.cloudreader:id/ll_item_top").get( 0).click();
  43. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='返回']").click();
  44. driver.findElementsById( "com.example.jingbin.cloudreader:id/ll_item_top").get( 0).click();
  45. driver.findElementByXPath( "//android.widget.ImageView[@content-desc='更多选项']").click();
  46. driver.findElementByXPath( "//android.widget.TextView[@text='分享到']").click();
  47. driver.sendKeyEvent(AndroidKeyCode.BACK);
  48. driver.findElementByXPath( "//android.widget.ImageView[@content-desc='更多选项']").click();
  49. driver.findElementByXPath( "//android.widget.TextView[@text='复制链接']").click();
  50. driver.findElementByXPath( "//android.widget.ImageView[@content-desc='更多选项']").click();
  51. driver.findElementByXPath( "//android.widget.TextView[@text='打开链接']").click();
  52. Thread.sleep( 500);
  53. driver.sendKeyEvent(AndroidKeyCode.BACK);
  54. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='返回']").click();
  55. driver.findElementByXPath( "//android.widget.TextView[@text='书籍']").click();
  56. Thread.sleep( 1000);
  57. driver.findElementByXPath( "//android.widget.TextView[@text='天才在左 疯子在右']").click();
  58. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  59. driver.findElementByXPath( "//android.widget.TextView[@text='天才在左 疯子在右']").click();
  60. driver.findElementByXPath( "//android.widget.ImageView[@content-desc='更多选项']").click();
  61. driver.findElementByXPath( "//android.widget.TextView[@text='更多信息']").click();
  62. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='返回']").click();
  63. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  64. driver.findElementByXPath( "//android.widget.TextView[@text='段子']").click();
  65. Thread.sleep( 1000);
  66. driver.findElementById( "com.example.jingbin.cloudreader:id/iv_title_two").click();
  67. Thread.sleep( 500);
  68. driver.findElementByXPath( "//android.widget.TextView[@text='每日推荐']").click();
  69. Thread.sleep( 500);
  70. driver.findElementByXPath( "//android.widget.TextView[@text='福利']").click();
  71. Thread.sleep( 500);
  72. driver.findElementByXPath( "//android.widget.TextView[@text='干货订制']").click();
  73. Thread.sleep( 500);
  74. driver.findElementByXPath( "//android.widget.TextView[@text='大安卓']").click();
  75. Thread.sleep( 500);
  76. driver.findElementById( "com.example.jingbin.cloudreader:id/iv_title_three").click();
  77. Thread.sleep( 1000);
  78. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_movie_top").click();
  79. Thread.sleep( 500);
  80. driver.findElementByXPath( "//android.widget.TextView[@text='肖申克的救赎']").click();
  81. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  82. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  83. driver.findElementById( "com.example.jingbin.cloudreader:id/action_search").click();
  84. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_title_menu").click();
  85. driver.findElementById( "com.example.jingbin.cloudreader:id/iv_avatar").click();
  86. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='返回']").click();
  87. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_nav_homepage").click();
  88. driver.findElementById( "com.example.jingbin.cloudreader:id/fab_share").click();
  89. driver.sendKeyEvent(AndroidKeyCode.BACK);
  90. driver.sendKeyEvent(AndroidKeyCode.BACK);
  91. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_title_menu").click();
  92. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_nav_scan_download").click();
  93. driver.findElementById( "com.example.jingbin.cloudreader:id/tv_share").click();
  94. Thread.sleep( 500);
  95. driver.sendKeyEvent(AndroidKeyCode.BACK);
  96. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  97. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_title_menu").click();
  98. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_nav_deedback").click();
  99. driver.findElementById( "com.example.jingbin.cloudreader:id/tv_issues").click();
  100. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='返回']").click();
  101. driver.findElementById( "com.example.jingbin.cloudreader:id/tv_faq").click();
  102. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='返回']").click();
  103. driver.findElementById( "com.example.jingbin.cloudreader:id/tv_qq").click();
  104. driver.findElementById( "com.example.jingbin.cloudreader:id/tv_email").click();
  105. Thread.sleep( 1000);
  106. driver.sendKeyEvent(AndroidKeyCode.BACK);
  107. driver.findElementById( "com.example.jingbin.cloudreader:id/tv_jianshu").click();
  108. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='返回']").click();
  109. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  110. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_title_menu").click();
  111. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_nav_about").click();
  112. driver.findElementById( "com.example.jingbin.cloudreader:id/tv_new_version").click();
  113. driver.findElementByXPath( "//android.widget.Button[@text='取消']").click();
  114. driver.findElementById( "com.example.jingbin.cloudreader:id/tv_function").click();
  115. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='返回']").click();
  116. driver.findElementById( "com.example.jingbin.cloudreader:id/tv_about_star").click();
  117. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='返回']").click();
  118. driver.findElementById( "com.example.jingbin.cloudreader:id/tv_wanandroid").click();
  119. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='返回']").click();
  120. driver.findElementById( "com.example.jingbin.cloudreader:id/tv_gankio").click();
  121. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='返回']").click();
  122. driver.findElementById( "com.example.jingbin.cloudreader:id/tv_douban").click();
  123. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='返回']").click();
  124. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  125. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_title_menu").click();
  126. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_nav_login").click();
  127. driver.findElementByXPath( "//android.widget.TextView[@text='GitHub账号']").click();
  128. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='返回']").click();
  129. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_title_menu").click();
  130. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_nav_login").click();
  131. driver.findElementByXPath( "//android.widget.TextView[@text='玩安卓账号']").click();
  132. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  133. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_title_menu").click();
  134. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_nav_collect").click();
  135. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  136. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_title_menu").click();
  137. driver.findElementById( "com.example.jingbin.cloudreader:id/ll_nav_exit").click();
  138. } catch (Exception e) {
  139. }
  140. }
  141. /**
  142. * AppiumDriver的初始化逻辑必须写在该函数中
  143. * @return
  144. */
  145. public AppiumDriver initAppiumTest() {
  146. AppiumDriver driver= null;
  147. File classpathRoot = new File(System.getProperty( "user.dir"));
  148. File appDir = new File(classpathRoot, "apk");
  149. File app = new File(appDir, "CloudReader.apk");
  150. //设置自动化相关参数
  151. DesiredCapabilities capabilities = new DesiredCapabilities();
  152. capabilities.setCapability( "browserName", "");
  153. capabilities.setCapability( "platformName", "Android");
  154. capabilities.setCapability( "deviceName", "Android Emulator");
  155. capabilities.setCapability( "appPackage", "com.example.jingbin.cloudreader");
  156. capabilities.setCapability( "appActivity", ".ui.TransitionActivity");
  157. capabilities.setCapability( "noSign", "true");
  158. //设置apk路径
  159. capabilities.setCapability( "app", app.getAbsolutePath());
  160. //设置使用unicode键盘,支持输入中文和特殊字符
  161. capabilities.setCapability( "unicodeKeyboard", "true");
  162. //设置用例执行完成后重置键盘
  163. capabilities.setCapability( "resetKeyboard", "true");
  164. //初始化
  165. try {
  166. driver = new AppiumDriver( new URL( "http://127.0.0.1:4723/wd/hub"), capabilities);
  167. } catch (MalformedURLException e) {
  168. // TODO Auto-generated catch block
  169. e.printStackTrace();
  170. }
  171. return driver;
  172. }
  173. public void start() {
  174. test(initAppiumTest());
  175. }
  176. public static void main(String[] args) {
  177. Main main = new Main();
  178. main.start();
  179. }
  180. }

  
  1. /*
  2. *
  3. * 第二题:
  4. * 快看漫画
  5. *
  6. */
  7. package com.mooctest;
  8. import io.appium.java_client.AppiumDriver;
  9. import io.appium.java_client.AndroidKeyCode;
  10. import java.io.File;
  11. import java.net.MalformedURLException;
  12. import java.net.URL;
  13. import java.util.List;
  14. import java.util.concurrent.TimeUnit;
  15. import org.openqa.selenium.By;
  16. import org.openqa.selenium.NoSuchElementException;
  17. import org.openqa.selenium.WebElement;
  18. import org.openqa.selenium.remote.CapabilityType;
  19. import org.openqa.selenium.remote.DesiredCapabilities;
  20. import org.openqa.selenium.remote.UnreachableBrowserException;
  21. public class Main {
  22. /**
  23. * "appPackage", "com.kuaikan.comic"
  24. * "app-launchActivity", "com.kuaikan.comic.ui.LaunchActivity"
  25. * 本示例脚本仅作为参考,具体请根据自己的测试机型可能出现的特殊情况进行脚本的编写调整
  26. */
  27. /**
  28. * 所有和AppiumDriver相关的操作都必须写在该函数中
  29. * @param driver
  30. */
  31. public void test(AppiumDriver driver) {
  32. try {
  33. Thread.sleep( 6000); //等待6s,待应用完全启动
  34. } catch (InterruptedException e) {
  35. // TODO Auto-generated catch block
  36. e.printStackTrace();
  37. }
  38. driver.manage().timeouts().implicitlyWait( 8, TimeUnit.SECONDS); //设置尝试定位控件的最长时间为8s,也就是最多尝试8s
  39. /*
  40. * 余下的测试逻辑请按照题目要求进行编写
  41. */
  42. try {
  43. driver.findElementById( "com.kuaikan.comic:id/btn_male").click();
  44. driver.findElementById( "com.kuaikan.comic:id/switch_gender_image").click();
  45. driver.findElementByXPath( "//android.widget.TextView[@text='推荐']").click();
  46. Thread.sleep( 500);
  47. driver.findElementByXPath( "//android.widget.TextView[@text='分类']").click();
  48. Thread.sleep( 500);
  49. driver.findElementByXPath( "//android.widget.TextView[@text='全部']").click();
  50. Thread.sleep( 500);
  51. driver.findElementByXPath( "//android.widget.TextView[@text='少年']").click();
  52. Thread.sleep( 500);
  53. driver.findElementByXPath( "//android.widget.TextView[@text='奇幻']").click();
  54. Thread.sleep( 500);
  55. driver.findElementByXPath( "//android.widget.TextView[@text='爆笑']").click();
  56. Thread.sleep( 500);
  57. driver.findElementByXPath( "//android.widget.TextView[@text='日漫']").click();
  58. Thread.sleep( 500);
  59. driver.findElementByXPath( "//android.widget.TextView[@text='灵异']").click();
  60. Thread.sleep( 500);
  61. driver.findElementByXPath( "//android.widget.TextView[@text='都市']").click();
  62. Thread.sleep( 500);
  63. driver.findElementByXPath( "//android.widget.TextView[@text='古风']").click();
  64. Thread.sleep( 500);
  65. driver.findElementByXPath( "//android.widget.TextView[@text='治愈']").click();
  66. Thread.sleep( 500);
  67. driver.findElementByXPath( "//android.widget.TextView[@text='恋爱']").click();
  68. Thread.sleep( 500);
  69. driver.findElementByXPath( "//android.widget.TextView[@text='校园']").click();
  70. Thread.sleep( 500);
  71. driver.findElementByXPath( "//android.widget.TextView[@text='正能量']").click();
  72. Thread.sleep( 500);
  73. driver.findElementByXPath( "//android.widget.TextView[@text='完结']").click();
  74. Thread.sleep( 500);
  75. driver.findElementByXPath( "//android.widget.TextView[@text='最火热']").click();
  76. Thread.sleep( 500);
  77. driver.findElementByXPath( "//android.widget.TextView[@text='新上架']").click();
  78. Thread.sleep( 500);
  79. driver.findElementById( "com.kuaikan.comic:id/search_image").click();
  80. driver.findElementById( "com.kuaikan.comic:id/search_input").click();
  81. driver.findElementById( "com.kuaikan.comic:id/search_bar_cancel").click();
  82. driver.findElementById( "com.kuaikan.comic:id/search_image").click();
  83. driver.findElementById( "com.kuaikan.comic:id/search_input").sendKeys( "龙珠");
  84. driver.findElementById( "com.kuaikan.comic:id/ic_search_searchbar_del").click();
  85. driver.findElementById( "com.kuaikan.comic:id/search_input").sendKeys( "龙珠");
  86. driver.findElementById( "com.kuaikan.comic:id/tv_searching").click();
  87. driver.findElementByXPath( "//android.widget.TextView[@text='龙珠']").click();
  88. driver.findElementById( "com.kuaikan.comic:id/activity_topic_back_layout").click();
  89. driver.findElementByXPath( "//android.widget.TextView[@text='龙珠']").click();
  90. driver.findElementById( "com.kuaikan.comic:id/topic_detail_header_collect").click();
  91. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  92. driver.findElementById( "com.kuaikan.comic:id/tab_info").click();
  93. driver.findElementByXPath( "//android.widget.TextView[@text='鸟山明']").click();
  94. driver.findElementById( "com.kuaikan.comic:id/activity_author_back_layout").click();
  95. driver.findElementByXPath( "//android.widget.TextView[@text='集英社']").click();
  96. driver.findElementById( "com.kuaikan.comic:id/activity_author_back_layout").click();
  97. driver.findElementById( "com.kuaikan.comic:id/user_v_layout").click();
  98. driver.findElementById( "com.kuaikan.comic:id/author_tab_info").click();
  99. driver.findElementById( "com.kuaikan.comic:id/author_tab_feed").click();
  100. driver.findElementById( "com.kuaikan.comic:id/subscribe_button").click();
  101. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  102. driver.findElementById( "com.kuaikan.comic:id/user_info_layout").click();
  103. driver.findElementById( "com.kuaikan.comic:id/toolbar_nav_icon").click();
  104. driver.findElementById( "com.kuaikan.comic:id/user_info_layout").click();
  105. driver.findElementById( "com.kuaikan.comic:id/feed_action_like").click();
  106. driver.findElementById( "com.kuaikan.comic:id/feed_comment").click();
  107. driver.sendKeyEvent(AndroidKeyCode.BACK);
  108. driver.findElementById( "com.kuaikan.comic:id/comment_edit").click();
  109. driver.findElementById( "com.kuaikan.comic:id/comment_send_layout").click();
  110. driver.sendKeyEvent(AndroidKeyCode.BACK);
  111. Thread.sleep( 500);
  112. driver.sendKeyEvent(AndroidKeyCode.BACK);
  113. driver.findElementById( "com.kuaikan.comic:id/tab_comic_list").click();
  114. driver.findElementById( "com.kuaikan.comic:id/wave_round_rect_layout").click();
  115. driver.findElementById( "com.kuaikan.comic:id/topic_detail_comic_order_img").click();
  116. driver.findElementById( "com.kuaikan.comic:id/tv_last_comic_name").click();
  117. driver.findElementById( "com.kuaikan.comic:id/toolbar_nav_icon").click();
  118. driver.findElementById( "com.kuaikan.comic:id/tv_continue_read").click();
  119. driver.findElementByXPath( "//android.widget.TextView[@text='全集']").click();
  120. driver.findElementById( "com.kuaikan.comic:id/tv_continue_read").click();
  121. driver.findElementById( "com.kuaikan.comic:id/send_btn").click();
  122. driver.findElementById( "com.kuaikan.comic:id/setting_img").click();
  123. driver.findElementById( "com.kuaikan.comic:id/vertical_flip_layout").click();
  124. driver.findElementById( "com.kuaikan.comic:id/setting_img").click();
  125. driver.findElementById( "com.kuaikan.comic:id/slide_flip_layout").click();
  126. driver.findElementById( "com.kuaikan.comic:id/setting_img").click();
  127. driver.findElementById( "com.kuaikan.comic:id/flip_switch_img").click();
  128. driver.findElementById( "com.kuaikan.comic:id/setting_img").click();
  129. driver.findElementById( "com.kuaikan.comic:id/night_mode_switch_img").click();
  130. Thread.sleep( 500);
  131. driver.sendKeyEvent(AndroidKeyCode.BACK);
  132. driver.findElementById( "com.kuaikan.comic:id/comment_share").click();
  133. driver.findElementByXPath( "//android.widget.TextView[@text='微博']").click();
  134. driver.sendKeyEvent(AndroidKeyCode.BACK);
  135. driver.findElementById( "com.kuaikan.comic:id/comment_share").click();
  136. driver.findElementByXPath( "//android.widget.TextView[@text='微信']").click();
  137. driver.findElementById( "com.kuaikan.comic:id/comment_share").click();
  138. driver.findElementByXPath( "//android.widget.TextView[@text='QQ']").click();
  139. driver.sendKeyEvent(AndroidKeyCode.BACK);
  140. driver.findElementById( "com.kuaikan.comic:id/comment_share").click();
  141. driver.findElementByXPath( "//android.widget.TextView[@text='QQ空间']").click();
  142. driver.findElementById( "com.kuaikan.comic:id/comment_share").click();
  143. driver.findElementByXPath( "//android.widget.TextView[@text='朋友圈']").click();
  144. driver.findElementById( "com.kuaikan.comic:id/comment_share").click();
  145. driver.findElementByXPath( "//android.widget.TextView[@text='收藏']").click();
  146. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  147. driver.findElementById( "com.kuaikan.comic:id/comment_share").click();
  148. driver.findElementByXPath( "//android.widget.TextView[@text='创建快捷方式']").click();
  149. driver.findElementById( "com.kuaikan.comic:id/comment_share").click();
  150. driver.findElementByXPath( "//android.widget.TextView[@text='举报']").click();
  151. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  152. driver.findElementById( "com.kuaikan.comic:id/comment_share").click();
  153. driver.findElementById( "com.kuaikan.comic:id/cancel").click();
  154. driver.findElementById( "com.kuaikan.comic:id/next_comic_img").click();
  155. driver.findElementById( "com.kuaikan.comic:id/pre_comic_img").click();
  156. } catch (Exception e) {
  157. System.out.println(e.getMessage());
  158. }
  159. }
  160. /**
  161. * AppiumDriver的初始化逻辑必须写在该函数中
  162. * @return
  163. */
  164. public AppiumDriver initAppiumTest() {
  165. AppiumDriver driver= null;
  166. File classpathRoot = new File(System.getProperty( "user.dir"));
  167. File appDir = new File(classpathRoot, "apk");
  168. File app = new File(appDir, "kuaikan.apk");
  169. //设置自动化相关参数
  170. DesiredCapabilities capabilities = new DesiredCapabilities();
  171. capabilities.setCapability( "browserName", "");
  172. capabilities.setCapability( "platformName", "Android");
  173. capabilities.setCapability( "deviceName", "Android Emulator");
  174. capabilities.setCapability( "appPackage", "com.kuaikan.comic");
  175. capabilities.setCapability( "appActivity", ".ui.LaunchActivity");
  176. capabilities.setCapability( "noSign", "true");
  177. //设置apk路径
  178. capabilities.setCapability( "app", app.getAbsolutePath());
  179. //设置app的主包名和主类名
  180. capabilities.setCapability( "appPackage", "com.kuaikan.comic");
  181. capabilities.setCapability( "appActivity", "com.kuaikan.comic.ui.LaunchActivity");
  182. //设置使用unicode键盘,支持输入中文和特殊字符
  183. capabilities.setCapability( "unicodeKeyboard", "true");
  184. //设置用例执行完成后重置键盘
  185. capabilities.setCapability( "resetKeyboard", "true");
  186. //初始化
  187. try {
  188. driver = new AppiumDriver( new URL( "http://127.0.0.1:4723/wd/hub"), capabilities);
  189. } catch (MalformedURLException e) {
  190. // TODO Auto-generated catch block
  191. e.printStackTrace();
  192. }
  193. return driver;
  194. }
  195. public void start() {
  196. test(initAppiumTest());
  197. }
  198. public static void main(String[] args) {
  199. Main main = new Main();
  200. main.start();
  201. }
  202. }

省赛

今年真是够巧合的,今年的省赛在我之前的学校比,本来还想着借这个机会回去看看,没想到移动测试被改成了互联网比赛,直接在网上做就好了。还是老样子两个脚本题,第一题是“中华万年历”81分多、第二题是“在意空气”100分,全国第6名成功进入总决赛,和我一块的那个同学也以第21名进入了总决赛。下面我把两个题的脚本写一下:


  
  1. /*
  2. *
  3. * 第一题:
  4. * 中华万年历
  5. * 我记得这个是98分多不到99分
  6. *
  7. */
  8. package com.mooctest;
  9. import io.appium.java_client.AppiumDriver;
  10. import io.appium.java_client.AndroidKeyCode;
  11. import java.io.File;
  12. import java.net.MalformedURLException;
  13. import java.net.URL;
  14. import java.util.List;
  15. import java.util.concurrent.TimeUnit;
  16. import org.openqa.selenium.By;
  17. import org.openqa.selenium.NoSuchElementException;
  18. import org.openqa.selenium.WebElement;
  19. import org.openqa.selenium.remote.CapabilityType;
  20. import org.openqa.selenium.remote.DesiredCapabilities;
  21. import org.openqa.selenium.remote.UnreachableBrowserException;
  22. public class Main {
  23. /**
  24. * 所有和AppiumDriver相关的操作都必须写在该函数中
  25. * @param driver
  26. * @throws InterruptedException
  27. */
  28. public void test(AppiumDriver driver) throws InterruptedException {
  29. try {
  30. Thread.sleep( 6000); //等待6s,待应用完全启动
  31. } catch (InterruptedException e) {
  32. // TODO Auto-generated catch block
  33. e.printStackTrace();
  34. }
  35. driver.manage().timeouts().implicitlyWait( 8, TimeUnit.SECONDS); //设置尝试定位控件的最长时间为8s,也就是最多尝试8s
  36. /*
  37. * 余下的测试逻辑请按照题目要求进行编写
  38. */
  39. try {
  40. driver.findElementById( "cn.etouch.ecalendar:id/relativeLayout_bottom_0").click();
  41. driver.findElementById( "cn.etouch.ecalendar:id/rl_toutiao_img").click();
  42. driver.findElementByXPath( "//android.widget.TextView[@text='活动']").click();
  43. driver.findElementByXPath( "//android.widget.TextView[@text='推荐']").click();
  44. driver.findElementByXPath( "//android.widget.TextView[@text='星座']").click();
  45. driver.findElementByXPath( "//android.widget.TextView[@text='美食']").click();
  46. driver.findElementByXPath( "//android.widget.TextView[@text='社会']").click();
  47. driver.findElementByXPath( "//android.widget.TextView[@text='时尚']").click();
  48. driver.findElementByXPath( "//android.widget.TextView[@text='情感']").click();
  49. driver.findElementByXPath( "//android.widget.TextView[@text='娱乐']").click();
  50. driver.findElementByXPath( "//android.widget.TextView[@text='热点']").click();
  51. driver.findElementByXPath( "//android.widget.TextView[@text='小说']").click();
  52. driver.findElementByXPath( "//android.widget.TextView[@text='奇闻']").click();
  53. driver.findElementByXPath( "//android.widget.TextView[@text='汽车']").click();
  54. driver.findElementByXPath( "//android.widget.TextView[@text='国际']").click();
  55. driver.findElementByXPath( "//android.widget.TextView[@text='搞笑']").click();
  56. driver.findElementByXPath( "//android.widget.TextView[@text='旅游']").click();
  57. driver.findElementByXPath( "//android.widget.TextView[@text='段子']").click();
  58. driver.findElementByXPath( "//android.widget.TextView[@text='亲子']").click();
  59. driver.findElementByXPath( "//android.widget.TextView[@text='养生']").click();
  60. driver.findElementByXPath( "//android.widget.TextView[@text='历史']").click();
  61. driver.findElementByXPath( "//android.widget.TextView[@text='科技']").click();
  62. driver.findElementByXPath( "//android.widget.TextView[@text='体育']").click();
  63. driver.findElementByXPath( "//android.widget.TextView[@text='教育']").click();
  64. driver.findElementByXPath( "//android.widget.TextView[@text='家居']").click();
  65. driver.findElementById( "cn.etouch.ecalendar:id/tv_more").click();
  66. Thread.sleep( 200);
  67. driver.findElementById( "cn.etouch.ecalendar:id/ll_edit").click();
  68. Thread.sleep( 200);
  69. driver.findElementsById( "cn.etouch.ecalendar:id/img_edit").get( 0).click();
  70. Thread.sleep( 200);
  71. driver.findElementById( "cn.etouch.ecalendar:id/iv_close").click();
  72. Thread.sleep( 200);
  73. driver.findElementsById( "cn.etouch.ecalendar:id/layout").get( 0).click();
  74. Thread.sleep( 200);
  75. driver.findElementById( "cn.etouch.ecalendar:id/btn_collect").click();
  76. Thread.sleep( 200);
  77. driver.findElementById( "cn.etouch.ecalendar:id/btn_know").click();
  78. Thread.sleep( 200);
  79. driver.findElementById( "cn.etouch.ecalendar:id/btn_more").click();
  80. driver.findElementById( "cn.etouch.ecalendar:id/ll_wxpy").click();
  81. Thread.sleep( 200);
  82. driver.findElementById( "cn.etouch.ecalendar:id/btn_more").click();
  83. driver.findElementById( "cn.etouch.ecalendar:id/ll_wx_pyq").click();
  84. Thread.sleep( 200);
  85. driver.findElementById( "cn.etouch.ecalendar:id/btn_more").click();
  86. driver.findElementById( "cn.etouch.ecalendar:id/ll_qq").click();
  87. Thread.sleep( 200);
  88. driver.findElementById( "cn.etouch.ecalendar:id/btn_more").click();
  89. driver.findElementById( "cn.etouch.ecalendar:id/ll_qzone").click();
  90. Thread.sleep( 200);
  91. driver.findElementById( "cn.etouch.ecalendar:id/btn_more").click();
  92. driver.findElementById( "cn.etouch.ecalendar:id/ll_sina").click();
  93. Thread.sleep( 200);
  94. driver.findElementById( "cn.etouch.ecalendar:id/ll_sms_life").click();
  95. Thread.sleep( 200);
  96. driver.findElementById( "cn.etouch.ecalendar:id/btn_more").click();
  97. driver.findElementById( "cn.etouch.ecalendar:id/ll_copy2clip").click();
  98. Thread.sleep( 200);
  99. driver.findElementById( "cn.etouch.ecalendar:id/btn_more").click();
  100. driver.findElementById( "cn.etouch.ecalendar:id/ll_other").click();
  101. driver.sendKeyEvent(AndroidKeyCode.BACK);
  102. Thread.sleep( 200);
  103. driver.findElementById( "cn.etouch.ecalendar:id/btn_more").click();
  104. driver.findElementsById( "cn.etouch.ecalendar:id/ll_item").get( 0).click();
  105. Thread.sleep( 200);
  106. driver.findElementById( "cn.etouch.ecalendar:id/btn_more").click();
  107. driver.findElementsById( "cn.etouch.ecalendar:id/ll_item").get( 1).click();
  108. driver.sendKeyEvent(AndroidKeyCode.BACK);
  109. Thread.sleep( 200);
  110. driver.findElementById( "cn.etouch.ecalendar:id/btn_more").click();
  111. driver.findElementById( "cn.etouch.ecalendar:id/tv_cancel").click();
  112. Thread.sleep( 200);
  113. driver.findElementById( "cn.etouch.ecalendar:id/tv_comment").click();
  114. Thread.sleep( 200);
  115. driver.findElementById( "cn.etouch.ecalendar:id/btn_back").click();
  116. Thread.sleep( 200);
  117. driver.findElementById( "cn.etouch.ecalendar:id/ettv_coment").click();
  118. driver.findElementById( "cn.etouch.ecalendar:id/ettv_zan").click();
  119. driver.findElementById( "cn.etouch.ecalendar:id/ettv_share").click();
  120. driver.findElementById( "cn.etouch.ecalendar:id/tv_cancel").click();
  121. Thread.sleep( 200);
  122. driver.findElementById( "cn.etouch.ecalendar:id/button1").click();
  123. Thread.sleep( 500);
  124. driver.findElementById( "cn.etouch.ecalendar:id/rl_back_calendar").click();
  125. Thread.sleep( 200);
  126. driver.findElementById( "cn.etouch.ecalendar:id/LinearLayout02").click();
  127. driver.findElementById( "cn.etouch.ecalendar:id/textView_gongli").click();
  128. driver.findElementById( "cn.etouch.ecalendar:id/textView_nongli").click();
  129. driver.findElementById( "cn.etouch.ecalendar:id/button_cancel").click();
  130. driver.findElementById( "cn.etouch.ecalendar:id/LinearLayout02").click();
  131. driver.findElementById( "cn.etouch.ecalendar:id/button_ok").click();
  132. Thread.sleep( 200);
  133. driver.findElementById( "cn.etouch.ecalendar:id/tv_add").click();
  134. Thread.sleep( 200);
  135. driver.findElementById( "cn.etouch.ecalendar:id/rl_task").click();
  136. driver.findElementById( "cn.etouch.ecalendar:id/rl_note").click();
  137. driver.findElementById( "cn.etouch.ecalendar:id/rl_todo").click();
  138. driver.findElementById( "cn.etouch.ecalendar:id/rl_fes").click();
  139. driver.findElementById( "cn.etouch.ecalendar:id/rl_alarm").click();
  140. driver.findElementById( "cn.etouch.ecalendar:id/btn_save").click();
  141. Thread.sleep( 200);
  142. driver.findElementById( "cn.etouch.ecalendar:id/layout_almanac").click();
  143. Thread.sleep( 200);
  144. driver.findElementById( "cn.etouch.ecalendar:id/tv_yunshi").click();
  145. driver.findElementById( "cn.etouch.ecalendar:id/tv_almanac").click();
  146. driver.findElementById( "cn.etouch.ecalendar:id/btn_share").click();
  147. driver.findElementById( "cn.etouch.ecalendar:id/tv_cancel").click();
  148. Thread.sleep( 200);
  149. driver.findElementById( "cn.etouch.ecalendar:id/title_gtime").click();
  150. driver.findElementById( "cn.etouch.ecalendar:id/button_ok").click();
  151. driver.findElementById( "cn.etouch.ecalendar:id/tv_date").click();
  152. driver.findElementById( "cn.etouch.ecalendar:id/button_ok").click();
  153. driver.findElementById( "cn.etouch.ecalendar:id/img_pre_date").click();
  154. driver.findElementById( "cn.etouch.ecalendar:id/img_next_date").click();
  155. driver.findElementById( "cn.etouch.ecalendar:id/img_next_date").click();
  156. driver.findElementById( "cn.etouch.ecalendar:id/btn_jin").click();
  157. driver.findElementById( "cn.etouch.ecalendar:id/tv_year").click();
  158. driver.findElementById( "cn.etouch.ecalendar:id/button_back").click();
  159. driver.findElementById( "cn.etouch.ecalendar:id/text_daoli").click();
  160. driver.findElementById( "cn.etouch.ecalendar:id/button_back").click();
  161. driver.findElementById( "cn.etouch.ecalendar:id/ll_yi_ji").click();
  162. driver.findElementById( "cn.etouch.ecalendar:id/button_back").click();
  163. driver.findElementById( "cn.etouch.ecalendar:id/image_jiri_search").click();
  164. driver.findElementById( "cn.etouch.ecalendar:id/text_yi").click();
  165. driver.findElementById( "cn.etouch.ecalendar:id/text_ji").click();
  166. driver.findElementById( "cn.etouch.ecalendar:id/btn_back").click();
  167. driver.findElementById( "cn.etouch.ecalendar:id/layout_compass").click();
  168. driver.findElementById( "cn.etouch.ecalendar:id/iv_cai").click();
  169. driver.findElementById( "cn.etouch.ecalendar:id/iv_xi").click();
  170. driver.findElementById( "cn.etouch.ecalendar:id/iv_fu").click();
  171. driver.findElementById( "cn.etouch.ecalendar:id/iv_yang").click();
  172. driver.findElementById( "cn.etouch.ecalendar:id/iv_yin").click();
  173. driver.findElementById( "cn.etouch.ecalendar:id/btn_back").click();
  174. driver.findElementById( "cn.etouch.ecalendar:id/tx_wuxing").click();
  175. driver.findElementById( "cn.etouch.ecalendar:id/button_back").click();
  176. driver.findElementById( "cn.etouch.ecalendar:id/tx_chongsha").click();
  177. driver.findElementById( "cn.etouch.ecalendar:id/button_back").click();
  178. driver.findElementById( "cn.etouch.ecalendar:id/tx_zhishen").click();
  179. driver.findElementById( "cn.etouch.ecalendar:id/button_back").click();
  180. driver.findElementById( "cn.etouch.ecalendar:id/ll_shieshen").click();
  181. driver.findElementById( "cn.etouch.ecalendar:id/button_back").click();
  182. driver.findElementById( "cn.etouch.ecalendar:id/ll_pengzu").click();
  183. driver.findElementById( "cn.etouch.ecalendar:id/button_back").click();
  184. driver.findElementById( "cn.etouch.ecalendar:id/ll_xingxiu").click();
  185. driver.findElementById( "cn.etouch.ecalendar:id/button_back").click();
  186. driver.findElementById( "cn.etouch.ecalendar:id/ll_xiongshen").click();
  187. driver.findElementById( "cn.etouch.ecalendar:id/button_back").click();
  188. driver.findElementById( "cn.etouch.ecalendar:id/ll_taishen").click();
  189. driver.findElementById( "cn.etouch.ecalendar:id/button_back").click();
  190. driver.findElementById( "cn.etouch.ecalendar:id/ll_jishen").click();
  191. driver.findElementById( "cn.etouch.ecalendar:id/button_back").click();
  192. driver.findElementById( "cn.etouch.ecalendar:id/ll_time_jixiong").click();
  193. driver.findElementById( "cn.etouch.ecalendar:id/btn_back").click();
  194. driver.findElementById( "cn.etouch.ecalendar:id/ll_almanac_fanyi").click();
  195. driver.findElementById( "cn.etouch.ecalendar:id/button_back").click();
  196. driver.findElementById( "cn.etouch.ecalendar:id/btn_back").click();
  197. driver.findElementById( "cn.etouch.ecalendar:id/relativeLayout_bottom_4").click();
  198. driver.findElementById( "cn.etouch.ecalendar:id/tv_city").click();
  199. driver.findElementById( "cn.etouch.ecalendar:id/btn_back").click();
  200. driver.findElementById( "cn.etouch.ecalendar:id/layout_city").click();
  201. driver.findElementById( "cn.etouch.ecalendar:id/btn_add").click();
  202. driver.findElementById( "cn.etouch.ecalendar:id/edt_selectCity_input").click();
  203. driver.findElementById( "cn.etouch.ecalendar:id/edt_selectCity_input").sendKeys( "北京");
  204. Thread.sleep( 2000);
  205. driver.findElementByXPath( "//android.widget.TextView[@text='北京, 中国']").click();
  206. driver.findElementById( "cn.etouch.ecalendar:id/btn_city_edit").click();
  207. driver.findElementById( "cn.etouch.ecalendar:id/iv_drag").click();
  208. driver.findElementsById( "cn.etouch.ecalendar:id/iv_edit").get( 0).click();
  209. driver.findElementById( "cn.etouch.ecalendar:id/tv_delete").click();
  210. driver.findElementById( "cn.etouch.ecalendar:id/btn_back").click();
  211. driver.findElementById( "cn.etouch.ecalendar:id/iv_ad_down").click();
  212. driver.findElementById( "cn.etouch.ecalendar:id/button1").click();
  213. driver.findElementById( "cn.etouch.ecalendar:id/ll_environemnt").click();
  214. driver.findElementById( "cn.etouch.ecalendar:id/btn_home").click();
  215. driver.findElementById( "cn.etouch.ecalendar:id/rl_jump").click();
  216. driver.findElementById( "cn.etouch.ecalendar:id/button1").click();
  217. driver.findElementById( "cn.etouch.ecalendar:id/tv_jump").click();
  218. driver.findElementById( "cn.etouch.ecalendar:id/button1").click();
  219. driver.findElementById( "cn.etouch.ecalendar:id/relativeLayout_bottom_3").click();
  220. driver.findElementById( "cn.etouch.ecalendar:id/iv_purchase").click();
  221. driver.findElementById( "cn.etouch.ecalendar:id/btn_wallet").click();
  222. driver.findElementById( "cn.etouch.ecalendar:id/tv_payment_record").click();
  223. driver.findElementById( "cn.etouch.ecalendar:id/btn_back").click();
  224. driver.findElementById( "cn.etouch.ecalendar:id/ll_score").click();
  225. driver.findElementById( "cn.etouch.ecalendar:id/button_back").click();
  226. driver.findElementByXPath( "//android.widget.TextView[@text='¥118']").click();
  227. driver.findElementById( "cn.etouch.ecalendar:id/btn_back").click();
  228. driver.findElementByXPath( "//android.widget.TextView[@text='¥218']").click();
  229. driver.findElementById( "cn.etouch.ecalendar:id/btn_back").click();
  230. driver.findElementByXPath( "//android.widget.TextView[@text='¥488']").click();
  231. driver.findElementById( "cn.etouch.ecalendar:id/btn_back").click();
  232. driver.findElementById( "cn.etouch.ecalendar:id/tv_back").click();
  233. driver.findElementById( "cn.etouch.ecalendar:id/text_empty_btn").click();
  234. driver.findElementById( "cn.etouch.ecalendar:id/btn_back").click();
  235. driver.findElementById( "cn.etouch.ecalendar:id/btn_back").click();
  236. driver.findElementById( "cn.etouch.ecalendar:id/relativeLayout_bottom_1").click();
  237. driver.findElementById( "cn.etouch.ecalendar:id/relativeLayout_bottom_2").click();
  238. } catch (Exception e) {
  239. }
  240. }
  241. /**
  242. * AppiumDriver的初始化逻辑必须写在该函数中
  243. * @return
  244. */
  245. public AppiumDriver initAppiumTest() {
  246. AppiumDriver driver= null;
  247. File classpathRoot = new File(System.getProperty( "user.dir"));
  248. File appDir = new File(classpathRoot, "apk");
  249. File app = new File(appDir, "Zhwnl.apk");
  250. //设置自动化相关参数
  251. DesiredCapabilities capabilities = new DesiredCapabilities();
  252. capabilities.setCapability( "browserName", "");
  253. capabilities.setCapability( "platformName", "Android");
  254. capabilities.setCapability( "deviceName", "Android Emulator");
  255. capabilities.setCapability( "appPackage", "cn.etouch.ecalendar");
  256. capabilities.setCapability( "appActivity", ".ECalendar");
  257. capabilities.setCapability( "noSign", "true");
  258. //设置apk路径
  259. capabilities.setCapability( "app", app.getAbsolutePath());
  260. //设置使用unicode键盘,支持输入中文和特殊字符
  261. capabilities.setCapability( "unicodeKeyboard", "true");
  262. //设置用例执行完成后重置键盘
  263. capabilities.setCapability( "resetKeyboard", "true");
  264. //初始化
  265. try {
  266. driver = new AppiumDriver( new URL( "http://127.0.0.1:4723/wd/hub"), capabilities);
  267. } catch (MalformedURLException e) {
  268. // TODO Auto-generated catch block
  269. e.printStackTrace();
  270. }
  271. return driver;
  272. }
  273. public void start() {
  274. try {
  275. test(initAppiumTest());
  276. } catch (InterruptedException e) {
  277. // TODO Auto-generated catch block
  278. e.printStackTrace();
  279. }
  280. }
  281. public static void main(String[] args) {
  282. Main main = new Main();
  283. main.start();
  284. }
  285. }

  
  1. /*
  2. *
  3. * 第二题:
  4. * 在意空气
  5. * 100分,100%覆盖率
  6. *
  7. */
  8. package com.mooctest;
  9. import io.appium.java_client.AppiumDriver;
  10. import io.appium.java_client.AndroidKeyCode;
  11. import java.io.File;
  12. import java.net.MalformedURLException;
  13. import java.net.URL;
  14. import java.util.List;
  15. import java.util.concurrent.TimeUnit;
  16. import org.openqa.selenium.By;
  17. import org.openqa.selenium.NoSuchElementException;
  18. import org.openqa.selenium.WebElement;
  19. import org.openqa.selenium.remote.CapabilityType;
  20. import org.openqa.selenium.remote.DesiredCapabilities;
  21. import org.openqa.selenium.remote.UnreachableBrowserException;
  22. public class Main {
  23. /**
  24. * 所有和AppiumDriver相关的操作都必须写在该函数中
  25. * @param driver
  26. */
  27. public void test(AppiumDriver driver) {
  28. try {
  29. Thread.sleep( 6000); //等待6s,待应用完全启动
  30. } catch (InterruptedException e) {
  31. // TODO Auto-generated catch block
  32. e.printStackTrace();
  33. }
  34. driver.manage().timeouts().implicitlyWait( 8, TimeUnit.SECONDS); //设置尝试定位控件的最长时间为8s,也就是最多尝试8s
  35. /*
  36. * 余下的测试逻辑请按照题目要求进行编写
  37. */
  38. try {
  39. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='在意空气']").click();
  40. driver.findElementById( "com.freshideas.airindex:id/mainNav_accountLayout_id").click();
  41. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  42. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='在意空气']").click();
  43. driver.findElementByXPath( "//android.widget.CheckedTextView[@text='空气质量指数']").click();
  44. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='在意空气']").click();
  45. driver.findElementByXPath( "//android.widget.CheckedTextView[@text='空气质量地图']").click();
  46. driver.findElementById( "com.freshideas.airindex:id/map_replayLayout_id").click();
  47. driver.findElementById( "com.freshideas.airindex:id/map_menuBtn_id").click();
  48. driver.sendKeyEvent(AndroidKeyCode.BACK);
  49. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='在意空气']").click();
  50. driver.findElementByXPath( "//android.widget.CheckedTextView[@text='排行榜']").click();
  51. driver.findElementById( "com.freshideas.airindex:id/rank_id").click();
  52. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  53. driver.findElementById( "com.freshideas.airindex:id/rank_best_id").click();
  54. driver.findElementById( "com.freshideas.airindex:id/rank_worst_id").click();
  55. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='在意空气']").click();
  56. driver.findElementByXPath( "//android.widget.CheckedTextView[@text='发现']").click();
  57. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='在意空气']").click();
  58. driver.findElementByXPath( "//android.widget.CheckedTextView[@text='编辑收藏地点列表']").click();
  59. driver.findElementById( "com.freshideas.airindex:id/menu_add_id").click();
  60. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  61. driver.findElementById( "com.freshideas.airindex:id/modifyCityItem_trash_id").click();
  62. driver.findElementById( "com.freshideas.airindex:id/modifyCityItem_delBtn_id").click();
  63. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  64. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='在意空气']").click();
  65. driver.findElementByXPath( "//android.widget.CheckedTextView[@text='编辑设备列表']").click();
  66. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  67. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='在意空气']").click();
  68. driver.findElementByXPath( "//android.widget.CheckedTextView[@text='设置']").click();
  69. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  70. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='在意空气']").click();
  71. driver.findElementByXPath( "//android.widget.CheckedTextView[@text='关于']").click();
  72. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  73. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='在意空气']").click();
  74. driver.findElementByXPath( "//android.widget.CheckedTextView[@text='空气质量指数']").click();
  75. driver.findElementById( "com.freshideas.airindex:id/menu_share_id").click();
  76. driver.findElementByXPath( "//android.widget.TextView[@text='保存到相册']").click();
  77. driver.findElementById( "com.freshideas.airindex:id/menu_share_id").click();
  78. driver.findElementByXPath( "//android.widget.TextView[@text='微博']").click();
  79. Thread.sleep( 5000);
  80. driver.sendKeyEvent(AndroidKeyCode.BACK);
  81. driver.findElementById( "com.freshideas.airindex:id/menu_share_id").click();
  82. driver.findElementByXPath( "//android.widget.TextView[@text='微信朋友圈']").click();
  83. driver.findElementById( "com.freshideas.airindex:id/menu_share_id").click();
  84. driver.findElementByXPath( "//android.widget.TextView[@text='微信好友']").click();
  85. driver.findElementById( "com.freshideas.airindex:id/menu_share_id").click();
  86. driver.findElementByXPath( "//android.widget.TextView[@text='QQ']").click();
  87. driver.findElementById( "com.freshideas.airindex:id/menu_share_id").click();
  88. driver.findElementByXPath( "//android.widget.TextView[@text='Twitter']").click();
  89. Thread.sleep( 3000);
  90. driver.sendKeyEvent(AndroidKeyCode.BACK);
  91. driver.findElementById( "com.freshideas.airindex:id/menu_share_id").click();
  92. driver.findElementByXPath( "//android.widget.TextView[@text='邮箱']").click();
  93. Thread.sleep( 3000);
  94. driver.sendKeyEvent(AndroidKeyCode.BACK);
  95. driver.findElementById( "com.freshideas.airindex:id/menu_share_id").click();
  96. driver.findElementByXPath( "//android.widget.TextView[@text='更多']").click();
  97. Thread.sleep( 3000);
  98. driver.sendKeyEvent(AndroidKeyCode.BACK);
  99. driver.findElementById( "com.freshideas.airindex:id/dashboard_footer_layout").click();
  100. driver.findElementByXPath( "//android.widget.ImageButton[@content-desc='转到上一层级']").click();
  101. driver.findElementById( "com.freshideas.airindex:id/dashboard_section_close").click();
  102. driver.findElementById( "com.freshideas.airindex:id/dashboard_promote_btn").click();
  103. driver.findElementsById( "com.freshideas.airindex:id/dashboard_name").get( 0).click();
  104. driver.findElementById( "com.freshideas.airindex:id/detail_info_id").click();
  105. driver.sendKeyEvent(AndroidKeyCode.BACK);
  106. driver.findElementByXPath( "//android.widget.TextView[@text='PM10']").click();
  107. driver.sendKeyEvent(AndroidKeyCode.BACK);
  108. driver.findElementByXPath( "//android.widget.TextView[@text='PM2.5']").click();
  109. driver.sendKeyEvent(AndroidKeyCode.BACK);
  110. driver.findElementByXPath( "//android.widget.TextView[@text='O3']").click();
  111. driver.sendKeyEvent(AndroidKeyCode.BACK);
  112. driver.findElementByXPath( "//android.widget.TextView[@text='NO2']").click();
  113. driver.sendKeyEvent(AndroidKeyCode.BACK);
  114. driver.findElementByXPath( "//android.widget.TextView[@text='CO']").click();
  115. driver.sendKeyEvent(AndroidKeyCode.BACK);
  116. driver.findElementByXPath( "//android.widget.TextView[@text='SO2']").click();
  117. driver.sendKeyEvent(AndroidKeyCode.BACK);
  118. } catch (Exception e) {
  119. }
  120. }
  121. /**
  122. * AppiumDriver的初始化逻辑必须写在该函数中
  123. * @return
  124. */
  125. public AppiumDriver initAppiumTest() {
  126. AppiumDriver driver= null;
  127. File classpathRoot = new File(System.getProperty( "user.dir"));
  128. File appDir = new File(classpathRoot, "apk");
  129. File app = new File(appDir, "Zykq.apk");
  130. //设置自动化相关参数
  131. DesiredCapabilities capabilities = new DesiredCapabilities();
  132. capabilities.setCapability( "browserName", "");
  133. capabilities.setCapability( "platformName", "Android");
  134. capabilities.setCapability( "deviceName", "Android Emulator");
  135. capabilities.setCapability( "appPackage", "com.freshideas.airindex");
  136. capabilities.setCapability( "appActivity", ".MainActivity");
  137. capabilities.setCapability( "noSign", "true");
  138. //设置apk路径
  139. capabilities.setCapability( "app", app.getAbsolutePath());
  140. //设置使用unicode键盘,支持输入中文和特殊字符
  141. capabilities.setCapability( "unicodeKeyboard", "true");
  142. //设置用例执行完成后重置键盘
  143. capabilities.setCapability( "resetKeyboard", "true");
  144. //初始化
  145. try {
  146. driver = new AppiumDriver( new URL( "http://127.0.0.1:4723/wd/hub"), capabilities);
  147. } catch (MalformedURLException e) {
  148. // TODO Auto-generated catch block
  149. e.printStackTrace();
  150. }
  151. return driver;
  152. }
  153. public void start() {
  154. test(initAppiumTest());
  155. }
  156. public static void main(String[] args) {
  157. Main main = new Main();
  158. main.start();
  159. }
  160. }

总决赛

其实今年的总决赛一直在纠结还去不去,新学校并没有参加过这个比赛,学校并不给报销差旅费。但是今年的省赛成绩还不错,想去冲一冲决赛,和我同学痛定思痛决定自费去参加决赛。

买了11月15号晚上的机票(晚上的便宜)(本土第一次坐飞机)。

跟我同学的计划是,下飞机后可以赶上南京最后一趟回市里的地铁, 坐地铁到南京南站,然后在南京南站北边找个网吧通宵一晚(为了刺激(主要是为了省钱))。

然而并没有我们安排的那样棒,飞机延误了半个小时,到达南京时已经快晚上十一点了,已经没有了地铁,此时我俩决定在体验一下机场的住宿条件,然后在按摩椅上睡了一晚。。。

第二天一早,赶着第一班地铁又来到了六朝古都。来到酒店放下行李,第一站当然是要去总统府

 此处省略总统府风景.....

----------------------------------------------------------------------------------------------------------

16号上午就是移动应用测试了,今年一共有3个题,第一个题是途牛的脚本题,第二题是途牛的众包题,第三题是..第三题我给忘了,也会一个脚本题。

也就是两个脚本题一个众包题,比去年的体量有些许增加,去年为两个题。总分为100分,3个题分别占33%,34%,33%。

脚本题

第一个途牛APP坑比较多,也浪费了我很多时间,大概用了两个半小时,最后分数提到了70多分不到80。

做完第一题比较慌了,还剩下一个半小时的时间,经验告诉我先做脚本题,脚本题拿分比较容易,拿到的分也是实实在在的分。第二个脚本题大概只用了半个多小时,因为要给众包题留时间。这个题比途牛要简单很多,最后只得了80多分,这个题如果再多点时间我感觉90分以上甚至满分都是没有问题的。

比赛前还在机房遇到了之前学校教过我的老师和他带领的同学们,亲切交谈了一番。

脚本题的分数在旁边的教室老师们可以实时查看,当我比赛完出来的时候,老师告诉我看到我的分数大概在十几名,我当时就想肯定是凉凉了,这次如果冲不到一等奖那我肯定是要赔本,就算是二等奖的1000奖金扣完税也就800快点肯定不够我机票和酒店的。

众包题

最后就是这个众包题了,其实在做第一题时可以顺带截一些BUG的图,因为在写脚本时遇到的几个异常退出的BUG写用例的时候我找不到了。。。众包题分为两个部分,一是写测试用例,二是找应用BUG,评分标准如下:

众包协作测试评分规则

本项比赛得到国家自然科学基金重大项目“基于互联网群体智能的软件开发方法研究”(61690200)支持,部分采用众包协作测试比赛内容,具体包括:

(1)测试用例设计(20 分)

(2)Bug 报告编写(60 分)

(3)Bug 报告审查(20 分)

(1)测试用例设计(20分)

  • 编写要求:(a)覆盖所有测试需求;(b)需求覆盖最大化的前提下减少用例执行工作量;(c)用例分类和描述清晰易懂。
  • 比赛规则:比赛过程选手独立完成,不能查看他人测试用例设计,自己根据测试需求进行测试用例编写。团队赛内部讨论完成,但只能用队长账号提交。
  • 评分规则:评审专家根据编写要求进行人工评分。

(2)Bug报告编写(60分)

  • 编写要求:Bug 截屏,Bug 报告文本包括环境、复现步骤和 Bug 描述等。

基本原则:(1)群体协作共同完成一个简洁准确完善的 Bug 报告集合;(2)编写 Bug 报告前后请认真审查其他报告,审查与编写同等重要;(3)评分原则鼓励协作,打击恶意刷分和浪费评审资源的行为。

  • 比赛规则:

比赛过程选手能查看所有的Bug报告。在查看他人报告的过程中,选手需要自行决定在他人报告基础上 Fork 后修改,还是新发起一个 Bug 报告。系统会根据 Fork 记录生成 Bug 报告树。特别注意,自己提交后的Bug 报告不能修改,但你可以 Fork 后进行修改。比赛鼓励尽可能在同一棵报告树上完成同类 Bug 报告。你认为当前 Bug报告已经存在你发现的 Bug,假如不完善你必须 Fork 后继续修改补充(是否点赞点踩自行决定)。另起一份新 Bug 报告树存在零分和负分的风险。

  • 评分规则:

1、(绝对分值生成)评审专家对每一份 Bug 报告文本和截屏进行评分,每一份 Bug 报告的分值是 0-10 分,0 分为无效报告,其他为有效报告。(贡献分值奖励)系统针对有效报告自动回溯计算每位选手的贡献度进行分数划分,比如报告 A 的分数 5 分,你 fork 修改后的报告 B 为 8 分,则你可以得 3 分;但是假如你 fork 修改后的报告分数低于 5,则记为 0分。

2、(冗余 Bug 报告惩罚)系统会对不存在 Fork 关系的 Bug 报告进行相似性计算并进行二次人工审查。【群体冗余惩罚】对于不同账号提交的 Bug报告判定为同类的,只保留提交最早的 Bug 报告分数,其他报告记 0 分。【个体冗余惩罚】对于同一账号提交的 Bug 报告判定为同类的,只保留提交最早的 Bug 报告分数,其他报告每个记-1 分。

3、(无效测试用例惩罚):每个 Bug 报告必须关联到对应的测试用例,测试用例关联错误的 Bug 报告判为 0 分。

4、Bug 报告编写分数累计到本项满分 60 为止,扣分到 0 分为止。

(3)Bug报告审查(20分)

  • 比赛规则:在查看所有报告(包括自己的)的过程中,对报告进行审查,认为有效报告的选择点赞 、认为无效报告的点踩,不能判断的不选择。
  • 评分规则:与专家审查结果一致(专家判断为有效报告选手点赞或者专家判定为无效报告你点踩)的记 1 分,不一致(专家判断为有效报告选手点踩或者专家判定为无效报告你点赞)的记-1 分,其他情况不计分。加分最多到本项满分 20 分为止,扣分到 0 分为止。恶意点踩等作弊行为本项判为 0 分。

 

 可以说今年的评分标准比去年改进了很多,不再像去年那样只看用例和BUG的数量。

测试用例最重要的一点就是——覆!盖!率!

不管你每一条写的怎么样,只要覆盖率高那么你的分数应该不会很低。

 

最后三个题的总分70.61393分,当我查到名次的时候还是很意外的,第四名,顺利拿到了一等奖(总算赔不了本了),脚本的分十几名我以为我顶多也就能进前十,没想到能拿到第四名。

回到学校后还有一件好消息就是学校得知我获得一等奖之后答应该我报销差旅费(不过机票只给按火车硬座报销),还是比较不错的哈哈哈。

后附几张青岛的夜景图:

胶州湾:

城阳区:

即墨区:


转载:https://blog.csdn.net/qq_17497931/article/details/84349791
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场