Exemplo n.º 1
0
        public static void init(this robotiumHelper.robotiumTestCase _tc)
        {
            //需要优化 每次都读
            //testRunDataDataContext trddc = new testRunDataDataContext();



            string ID = "null";

            var appXE = _tc.caseXml.XPathSelectElement("//Step[@name='R_InitStep']/ParamBinding[@name='applicationID']");

            if (appXE != null)
            {
                ID = appXE.Attribute("value").Value;
                if (string.IsNullOrEmpty(ID))
                {
                    ID = "null";
                }
            }



            var app = testHelper.rc.GetApk(ID);



            _tc.RunApk  = app.robotiumApk;
            _tc.package = app.androidPackeg;
            _tc.isClear = app.clearCache;
        }
Exemplo n.º 2
0
        private void RunInit(string rPath)
        {
            //创建结果目录
            if (!Directory.Exists(rPath))
            {
                Directory.CreateDirectory(rPath);
            }
            else
            {
                DirectoryInfo dirInfo = new DirectoryInfo(rPath);
                FileInfo[]    files   = dirInfo.GetFiles();
                //logHelper.info("file.Delete size:" + files.Count());
                //删除不了会报错
                foreach (FileInfo file in files)
                {
                    //logHelper.info("file.Delete:" + file.FullName);
                    try { file.Delete(); }
                    catch (Exception e)
                    {
                        logHelper.error(e);
                    }
                }
            }


            if (caseHelper is appiumHelper.appiumTestCase)//如果是appium 初始化
            {
                caseHelper.caseXml = this.caseXml;
                (caseHelper as appiumHelper.appiumTestCase).init();
            }
            else
            {
                if (caseHelper != null)
                {
                    caseHelper.CloseAll();
                }

                XElement step = caseXml.Descendants("Step").FirstOrDefault();

                string name = "R_initStep";//随便赋值的
                if (step != null)
                {
                    name = step.Attribute("name").Value;
                }


                if (name.Contains("R_"))//robotium 初始化
                {
                    //logHelper.info("init.robotium: start");

                    var help = new robotiumHelper.robotiumTestCase();


                    help.device  = this.device;
                    help.caseXml = this.caseXml;
                    help.init();

                    //runApk 相同
                    if (caseHelper is robotiumHelper.robotiumTestCase && ((robotiumHelper.robotiumTestCase)caseHelper).RunApk == help.RunApk)
                    {
                        help.install = false;
                    }
                    else
                    {
                        help.install = true;
                    }
                    caseHelper = help;
                }
                else if (name.Contains("UI_"))//uiautomator 初始化
                {
                    var help = new UiautomatorHelper.UiautomatorTestCase();
                    caseHelper = help;

                    help.device  = this.device;
                    help.caseXml = this.caseXml;
                }
                else //chrome 初始化
                {
                    var help = new chromeHelper.chromeTestCase(device, port);
                    caseHelper = help;

                    help.caseXml = this.caseXml;
                }
            }
        }