51Testing软件测试论坛

标题: appium如何解决每次都要安装apk的烦恼 [打印本页]

作者: 听海——sky    时间: 2018-4-9 15:30
标题: appium如何解决每次都要安装apk的烦恼
1、appium上勾选 No Reset

2、程序加上:capabilities.setCapability("noReset", true);   //不需要再次安装

3、命令行模式启动appium 加命令 --no reset ,可惜我不能通过命令行启动appium,所以这个我也没试过;

ps:如果老是要安装下图那3个apk,例如小米3就会这样,还没去查原因,那就换一类手机试试看;
[attach]113085[/attach]





  1. @BeforeMethod
  2. public void setUp() throws Exception{
  3. //set up appium设置apk路径
  4. File classpathRoot=new File(System.getProperty("user.dir"));
  5. File appDir=new File(classpathRoot, "apps");
  6. File app=new File(appDir, "hlct_201604141758_2_0_1_release_signed.apk");
  7. //设置自动化相关参数
  8. DesiredCapabilities capabilities=new DesiredCapabilities();
  9. // capabilities.setCapability("noReset", true); //不需要再次安装
  10. capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
  11. capabilities.setCapability("platformName","Android");
  12. capabilities.setCapability("deviceName","m1 metal");
  13. //设置android系统版本
  14. capabilities.setCapability("platformVersion","5.1.4");
  15. //if no need install don't add this
  16. //设置apk 的路径
  17. capabilities.setCapability("app",app.getAbsolutePath());

  18. //support Chinese支持中文输入
  19. capabilities.setCapability("unicodeKeyboard","True");
  20. //重置输入法为系统默认
  21. capabilities.setCapability("resetKeyboard","True");

  22. //no need sign 安装时不对apk进行重签名,设置很有必要,否则有的apk在重签名之后无法正常使用
  23. capabilities.setCapability("noSign","True");
  24. //设置app的主包名和主类名
  25. capabilities.setCapability("appPackage","com.my089");
  26. // capabilities.setCapability("appActivity","cn.jpush.android.ui.PushActivity");
  27. capabilities.setCapability("appActivity","com.my089.activity.welcome.WelcomeActivity");//找开发要或是第一个activity
  28. //初始化
  29. driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
  30. }
复制代码

[attach]113086[/attach]
[attach]113087[/attach]







欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2