Example #1
0
        protected void SaveScreenShot()
        {
            var imgPath = screenShotPathTemplate.Replace("[_IDX_]", $"{screenShotIndex:000}");

            ScreenShotHelper.Capture(driver, imgPath);

            screenShotIndex++;
        }
        private void MethodInfoInvole(RemoteWebDriver driver, string basepath, TestResultInfo dirInfo, SeleniumTestBase instance, MethodInfo mi, object[] param)
        {
            try
            {
                mi.Invoke(instance, param);
            }
            catch (Exception e)
            {
                dirInfo.Exceptions.Add(new ErrorInfo
                {
                    ClassName = mi.DeclaringType.Name,
                    TestName  = mi.Name,
                    Message   = e.ToString(),
                });
            }
            dirInfo.ExecutedIndex++;
            SaveJson(dirInfo, basepath);
            try
            {
                var imgName = GenFileName(mi, param);
                var imgPath = Path.Combine(basepath, dirInfo.DirId, imgName);


                ScreenShotHelper.Capture(driver, imgPath);

                foreach (var item in instance.Errors)
                {
                    item.ClassName = mi.DeclaringType.Name;
                    item.TestName  = mi.Name;
                }

                dirInfo.Errors.AddRange(instance.Errors);
                instance.Errors.Clear();
                SaveJson(dirInfo, basepath);
            }
            catch
            {
            }
        }