zoukankan      html  css  js  c++  java
  • Appium 一个测试套件多次启动android应用

     AppiumDriver<WebElement> driver;     
             File classpathRoot = new File(System.getProperty("user.dir"));        
                File appDir = new File(classpathRoot, "app");
                // 微信程序
                File app = new File(appDir, "xxxx.sp1_test2.apk");     
             
                //设置自动化相关参数
                DesiredCapabilities capabilities = new DesiredCapabilities();       
                capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
                capabilities.setCapability("deviceName", "192.168.56.101:5555");
                capabilities.setCapability("udid", "192.168.56.101:5555");
                //设置每次运行不重新启动被测试app
                capabilities.setCapability("noReset","true");
                capabilities.setCapability("fullReset","false");     
                //设置安卓系统版本
                capabilities.setCapability("platformVersion", "4.4");       
                capabilities.setCapability("platformName", "Android");
                // session 延迟时间
                capabilities.setCapability("newCommandTimeout",24000);
                capabilities.setCapability("device", "selendroid");        
                capabilities.setCapability("app", app.getAbsolutePath()); 
                String abc = app.getAbsolutePath();
                //设置app的主包名和主类名                                                              
                capabilities.setCapability("appPackage", "com.sf.module.edms");
                capabilities.setCapability("appActivity", "com.sf.module.edms.hibox.ui.entry.EntryActivity");       
                //启动
                 try {
                    driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
                } catch (MalformedURLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } 

    多次运行,就会出错

    01:5555","fullReset":"false","appActivity":"com.sf.module.edms.hibox.ui.entry.EntryActivity","newCommandTimeout":24000,"platformVersion":"4.4","browserName":"","udid":"192.168.56.101:5555","platformName":"Android","device":"selendroid"}}

    > info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_45)

    > error: Failed to start an Appium session, err was: Error: Requested a new session but one was in progress

    增加语句

    driver.closeApp();
    driver.quit();

    并且在appium里面设置

    tool ->general settings- > select overriding existing sessions

    在一个测试任务中,多次启动app driver 都能正常启动

  • 相关阅读:
    现代软件工程 第八章 【需求分析】练习与讨论
    现代软件工程 第七章 【MSF】练习与讨论
    现代软件工程 第六章 【敏捷流程】练习与讨论
    PPT演说技巧
    Mac上最强大的截图软件-xnip
    什么是函数倾轧(name mangling)?
    编程--在线提交系统(Online Judge)
    C++ 的多继承与虚继承
    C++ 中 string和char* 的区别
    编程语言中优先级与结合性
  • 原文地址:https://www.cnblogs.com/testway/p/5363804.html
Copyright © 2011-2022 走看看