Пример #1
0
        public void SetupTest()
        {
            _gppd        = new GPPD();
            _bldr        = new BLD();
            _awsS3       = new AWSS3();
            _contexte    = TestContext.CurrentContext;
            vTStampDebut = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            #region Parametres entrant
            url         = TestContext.Parameters.Get("Url", "");
            deviceOsV   = TestContext.Parameters.Get("DeviceOs", "Windows10");
            browserType = TestContext.Parameters.Get("Browser", "Chrome");
            dataId      = TestContext.Parameters.Get("DataID", "1");
            idConfig    = TestContext.Parameters.Get("IDConfiguration", "1");
            userName    = TestContext.Parameters.Get("PortMobile", "Lorem");
            userLName   = TestContext.Parameters.Get("IDConfiguration", "Ipsum");
            cmpName     = TestContext.Parameters.Get("CampaignName", "1");
            testType    = TestContext.Parameters.Get("TestType", "Fonctionnel");
            #endregion

            // Parser typeBrowser
            _browserType = (BrowserType)Enum.Parse(typeof(BrowserType), browserType);
            // Le passer a notre methode
            ChooseDriverInstance(_browserType);
            // Visiter la page
            _driver.Navigate().GoToUrl(url);
            // Tester la page
            _hndlr.serverResponse = _hndlr.serverCodeResponse(pageEtat);

            // Parser testType
            _testType = (TypeDeTest)Enum.Parse(typeof(TypeDeTest), testType);

            #region JS ~Metrics
            //-----------------------------
            // JS recuperation données HTML
            //-----------------------------
            IJavaScriptExecutor js = (IJavaScriptExecutor)_driver;
            loadEventEnd       = (long)js.ExecuteScript("return window.performance.timing.loadEventEnd");
            navigationStart    = (long)js.ExecuteScript("return window.performance.timing.navigationStart");
            title              = (string)js.ExecuteScript("return document.title");
            charset            = (string)js.ExecuteScript("return document.charset");
            _tagImg            = js.ExecuteScript("return document.images");
            _tagAComplet       = js.ExecuteScript("return document.anchors");
            _tagA              = js.ExecuteScript("return document.applets");
            _tagBody           = js.ExecuteScript("return document.body");
            _docMode           = js.ExecuteScript("return document.documentMode");
            _scripts           = js.ExecuteScript("return document.scripts");
            readyStateComplete = ((String)js.ExecuteScript("return document.readyState")).Equals("complete");
            #endregion

            /*
             * if (_testType == TypeDeTest.Fonctionnel)
             * {
             *  //------------------------
             *  // TestCase RECUPERRATION
             *  //------------------------
             *  TestCase Script = _gppd.ChargerTestCase();
             *
             *  foreach (var action in Script.Action)
             *  {
             *      _bldr.ScriptBuilderDESKTOP(action, _driver, _ssb, deviceUDID, userName, userLName, "DESKTOP", pageEtat);
             *  }
             * }*/
            //temps de chargement de page.
            tempsDeChargement = loadEventEnd - navigationStart;
        }
Пример #2
0
        public void SetupTest()
        {
            _bldr        = new BLD();
            _gppd        = new GPPD();
            _contexte    = TestContext.CurrentContext;
            vTStampDebut = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            #region Parametres entrant
            deviceUDID = TestContext.Parameters.Get("DeviceUDID", "9885b635494d373655");
            deviceName = TestContext.Parameters.Get("DeviceName", "SM-G930F");
            deviceOsV  = TestContext.Parameters.Get("TestCaseName", "7.0.0");
            dataId     = TestContext.Parameters.Get("DataID", "1");
            portMobile = TestContext.Parameters.Get("PortMobile", "4723");
            idConfig   = TestContext.Parameters.Get("IDConfiguration", "1");
            userName   = TestContext.Parameters.Get("PortMobile", "4723");
            userLName  = TestContext.Parameters.Get("IDConfiguration", "1");
            cmpName    = TestContext.Parameters.Get("CampaignName", "1");
            testType   = TestContext.Parameters.Get("TestType", "Fonctionnel");
            #endregion

            #region Capabilitées DRIVER
            DesiredCapabilities _cap = new DesiredCapabilities();
            _cap.SetCapability("autoGrantPermissions", "true");
            //_cap.SetCapability(MobileCapabilityType.App, @"C:\Users\User\Downloads\ucbrowser.apk");

            _cap.SetCapability(MobileCapabilityType.BrowserName, MobileBrowserType.Chrome);
            //_cap.SetCapability(AndroidMobileCapabilityType.AppPackage, "fr.francetv.apps.info");
            //_cap.SetCapability(AndroidMobileCapabilityType.AppActivity, "fr.francetv.apps.info.activity.home.HomeActivity");
            //_cap.SetCapability(MobileCapabilityType.FullReset, true);

            _cap.SetCapability(MobileCapabilityType.PlatformName, MobilePlatform.Android);
            _cap.SetCapability(MobileCapabilityType.NewCommandTimeout, 18000);
            _cap.SetCapability(MobileCapabilityType.Udid, deviceUDID);
            _cap.SetCapability(MobileCapabilityType.DeviceName, deviceName);
            _cap.SetCapability(MobileCapabilityType.PlatformVersion, deviceOsV);
            _cap.SetCapability(AndroidMobileCapabilityType.UnicodeKeyboard, true);
            _cap.SetCapability(AndroidMobileCapabilityType.ResetKeyboard, true);
            #endregion

            //Etat Appium?! When DEBUG MODE
            _hndlr.StartRemoteAppiumNode(portMobile, deviceUDID);
            // Parser testType
            _testType = (TypeDeTest)Enum.Parse(typeof(TypeDeTest), testType);

            try
            {
                //string xx = "http://" + ConfigurationManager.AppSettings["IPADDRESS"] + ":" + portMobile + "/wd/hub";
                _driverANDROID = new AndroidDriver <AndroidElement>(new Uri("http://" + ConfigurationManager.AppSettings["IPADDRESS"] + ":" + portMobile + "/wd/hub"), _cap);
                //_processActuel = AndroidRecordStart();
                //BuilderRecord("record");
                //_hndlr.serverResponse = _hndlr.serverCodeResponse(pageEtat);

                /*
                 #region JS ~Metrics
                 * IJavaScriptExecutor js = (IJavaScriptExecutor)_driverANDROID;
                 * loadEventEnd = (long)js.ExecuteScript("return window.performance.timing.loadEventEnd");
                 * navigationStart = (long)js.ExecuteScript("return window.performance.timing.navigationStart");
                 * title = (string)js.ExecuteScript("return document.title");
                 * charset = (string)js.ExecuteScript("return document.charset");
                 * _tagImg = js.ExecuteScript("return document.images");
                 * _tagAComplet = js.ExecuteScript("return document.anchors");
                 * _tagA = js.ExecuteScript("return document.applets");
                 * _tagBody = js.ExecuteScript("return document.body");
                 * _docMode = js.ExecuteScript("return document.documentMode");
                 * _scripts = js.ExecuteScript("return document.scripts");
                 * readyStateComplete = ((String)js.ExecuteScript("return document.readyState")).Equals("complete");
                 #endregion
                 * /*
                 * if (_testType == TypeDeTest.Fonctionnel)
                 * {
                 *  //------------------------
                 *  // TestCase RECUPERRATION
                 *  //------------------------
                 *  TestCase Script = _gppd.ChargerTestCase();
                 *
                 *  foreach (var action in Script.Action)
                 *  {
                 *      _bldr.ScriptBuilder(action, _driverANDROID, _ssb, deviceUDID, userName, userLName, "Android", pageEtat);
                 *  }
                 * }*/
                //tempsDeChargement = loadEventEnd - navigationStart;
            }
            catch (Exception ex)
            {
            }
        }