コード例 #1
0
        public void TakeScreenTest()
        {
            var bm = ScreenshotUtil.TakeScreen(0, 0, Tuple.Create(20, 10));

            Assert.AreEqual(20, bm.Size.Width);
            Assert.AreEqual(10, bm.Size.Height);
        }
コード例 #2
0
        private void Update()
        {
            if (!_recording)
            {
                return;
            }

            float t = Time.unscaledTime - _lastRecordTime;

            if (t > (1f / _frequency))
            {
                _frameCount++;
                _lastRecordTime = Time.unscaledTime;

                string fn;
                if (_timestamp)
                {
                    fn = string.Format("Image{0}{1:yyyyMMdd_HHmmss_fff}{2}", _frameCount, System.DateTime.Now, ScreenshotUtil.GetExtension(_format));
                }
                else
                {
                    fn = string.Format("Image{0}{1}", _frameCount, ScreenshotUtil.GetExtension(_format));
                }

                ScreenshotUtil.TakeScreenshot(System.IO.Path.Combine(_filePath, fn), _format);
                _status = "Recorded " + fn;
                this.Repaint();
            }
        }
コード例 #3
0
ファイル: TestBase.cs プロジェクト: vamseegit/SpecFlow
        internal void InitializeTest()
        {
            ReportUtil.AddTestcaseDetailsToExtentReport();
            browser = ConfigurationManager.AppSettings["Browser"].ToLower();
            url     = ConfigurationManager.AppSettings["URL"];
            switch (browser)
            {
            case "chrome":
                driver = new ChromeDriver();
                break;

            case "firefox":
                driver = new FirefoxDriver();
                break;

            case "ie":
                driver = new InternetExplorerDriver();
                break;

            default:
                throw new Exception("Browser name is not properly mentioned in the App.config file.");
            }
            driver.Manage().Window.Maximize();
            driver.Url = url;
            int waitTime = Convert.ToInt32(ConfigurationManager.AppSettings["WaitTime"]);

            wait           = new WebDriverWait(driver, TimeSpan.FromSeconds(waitTime));
            ScreenshotUtil = new ScreenshotUtil(driver);
        }
コード例 #4
0
        public string ObterMensagem()
        {
            ScreenshotUtil.Create(webDriver, $"CriarContaDeCliente_{DateTime.Now.ToString("ddMMyyyHHmmss")}.png");

            var element = webDriver.FindElement(By.CssSelector("body > div > div > div.main-container.col2-left-layout > div > div.col-main > div > div > ul > li > ul > li > span"));

            return(element.Text);
        }
コード例 #5
0
    public void BeforeSuit()
    {
        htmlReporter = new ExtentHtmlReporter(@"D:\Next Day Blinds\UnitTestNDBProject\UnitTestNDBProject\UnitTestNDBProject\Report\EReport.html");
        htmlReporter.Config.Theme         = Theme.Dark;
        htmlReporter.Config.DocumentTitle = "Test Report | Khushboo Kapoor";
        htmlReporter.Config.ReportName    = "KK Test Report | Khushboo Kapoor";
        extent = new ExtentReports();
        extent.AttachReporter(htmlReporter);
        Initialization();

        OpenURL();
        ScreenshotUtil.SaveScreenShot("firstfile");
    }
コード例 #6
0
        public void AfterStep(FeatureContext feature, ScenarioContext scenario)
        {
            var driver = feature.Get <Navigator>(App).Driver;

            if (scenario.TestError != null)
            {
                ScreenshotUtil.TakeScreenshot(
                    driver,
                    feature.FeatureInfo.Title.ToIdentifier(),
                    scenario.ScenarioInfo.Title.ToIdentifier(),
                    $"{DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()} \n{scenario.ScenarioInfo.Title} \n{scenario.TestError.Message}");
            }
        }
コード例 #7
0
ファイル: VsTestInvoker.cs プロジェクト: sharwell/VsixTesting
        private void TakeScreenShot(string name)
        {
            try
            {
                var safename = string.Join("_", name.Split(Path.GetInvalidFileNameChars()));
                var date     = DateTime.Now.ToString("yyyy-MM-dd hh.mm.ss");
                var path     = Path.Combine(Settings.ScreenshotsDirectory, $"{date} {safename}.png");

                Directory.CreateDirectory(Path.GetDirectoryName(path));
                ScreenshotUtil.CaptureWindow(Process.GetCurrentProcess().MainWindowHandle, path);
            }
            catch (Exception e)
            {
                Aggregator.Add(new Exception("Failed saving screenshot", e));
            }
        }
コード例 #8
0
ファイル: BaseTestClass.cs プロジェクト: kkapoor84/NDBCopy
        public void BeforeClassInitialization()
        {
            if (ConfigurationManager.AppSettings["Browser"] == "Chrome")
            {
                driver = new ChromeDriver();
            }
            else if (ConfigurationManager.AppSettings["Browser"] == "Firefox")
            {
                driver = new FirefoxDriver();
            }

            LoginPage_      = new LoginPage(driver);
            SearchPage_     = new SearchPage(driver);
            BasePageClass_  = new BasePageClass(driver);
            HomePage_       = new HomePage(driver);
            ScreenshotUtil_ = new ScreenshotUtil(driver);

            ScreenshotUtil_.SaveScreenShot($"Failed Test{this.GetType().Name}");
            BasePageClass_.OpenURL();

            _logger.Info($" :Successfully executed the BeforeClassInitialization() method for {this.GetType().Name}");
        }
コード例 #9
0
        public void BeforeClassInitialization()
        {
            if (ConfigurationManager.AppSettings["Browser"] == "Chrome")
            {
                driver = new ChromeDriver();
            }
            else if (ConfigurationManager.AppSettings["Browser"] == "Firefox")
            {
                driver = new FirefoxDriver();
            }

            _ScreenshotUtil       = new ScreenshotUtil(driver);
            _LoginPage            = new LoginPage(driver);
            _BasePageClass        = new BasePageClass(driver);
            _HomePage             = new HomePage(driver);
            _EnterNewCustomerPage = new EnterNewCustomerPage(driver);
            _QuotePage            = new QuotePage(driver);

            _BasePageClass.OpenURL();

            _logger.Info($" :Successfully executed the BeforeClassInitialization() method for {this.GetType().Name}");
        }
コード例 #10
0
        private static IEnumerator TakeScreenshots()
        {
            _isMakingScreenshotsNow = true;
            var currentIndex = GameViewUtil.GetCurrentSizeIndex();

            // Slow down and unpause editor if required
            var paused    = EditorApplication.isPaused;
            var timeScale = Time.timeScale;

            try
            {
                EditorApplication.isPaused = false;
                Time.timeScale             = 0.001f;

                var configsCount = _settings.ScreenshotConfigs.Count;
                for (var i = 0; i < configsCount; i++)
                {
                    var data = _settings.ScreenshotConfigs[i];

                    // Show progress
                    var info = (i + 1) + " / " + configsCount + " - " + data.Name;
                    EditorUtility.DisplayProgressBar("Taking Screenshots", info, (float)(i + 1) / configsCount);

                    // apply custom resolution for game view
                    var sizeType      = GameViewSizeType.FixedResolution;
                    var sizeGroupType = GameViewUtil.GetCurrentGroupType();
                    var sizeName      = "scr_" + data.Width + "x" + data.Height;

                    if (!GameViewUtil.IsSizeExist(sizeGroupType, sizeName))
                    {
                        GameViewUtil.AddCustomSize(sizeType, sizeGroupType, data.Width, data.Height, sizeName);
                    }

                    var index = GameViewUtil.FindSizeIndex(sizeGroupType, sizeName);
                    GameViewUtil.SetSizeByIndex(index);

                    // add some delay while applying changes
                    var lastFrameTime = EditorApplication.timeSinceStartup;
                    while (EditorApplication.timeSinceStartup - lastFrameTime < 0.2f)
                    {
                        yield return(null);
                    }
                    ScreenshotUtil.TakeScreenshot(_settings, data);
                    yield return(new WaitForSecondsRealtime(0.5f));

                    // just clean it up
                    GameViewUtil.RemoveCustomSize(sizeGroupType, index);
                }
            }
            finally
            {
                // Restore pause state and time scale
                EditorApplication.isPaused = paused;
                Time.timeScale             = timeScale;

                GameViewUtil.SetSizeByIndex(currentIndex);
                EditorUtility.ClearProgressBar();

                _isMakingScreenshotsNow = false;
            }
        }
コード例 #11
0
        //截图每个解决方案
        static public bool createScreenShot(ProgressMeter pm)
        {
            var doc = Application.DocumentManager.MdiActiveDocument;

            if (doc == null)
            {
                return(false);
            }

            CropMessage message = new CropMessage();
            Rectangle   rect    = new Rectangle();
            bool        Crop    = false;

            if (message.ShowDialog() == false)
            {
                if (message.SelectedValue == true)
                {
                    Crop = true;
                    bool status = ScreenshotUtil.SelectCropArea(out rect);
                    if (status == false)
                    {
                        return(false);
                    }
                }
            }
            int number_display = 10;//进度条的进度;

            if (solutions.Count <= 0)
            {
                return(false);
            }
            int len = (100 - number_display) / solutions.Count;

            foreach (var i_solution in solutions)
            {
                //隐藏云线
                solutionPanel.chrometabs.ChangeSelectedItem(i_solution.TabItem);
                HeatSourceLayoutApp.currentSolution = i_solution;
                using (DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
                {
                    using (Transaction tr = doc.Database.TransactionManager.StartTransaction())
                    {
                        foreach (var district in i_solution.Districts)
                        {
                            Entity obj = (Entity)(tr.GetObject(district.Value.BaseObjectId, OpenMode.ForRead));
                            if (!obj.IsErased)
                            {
                                obj.UpgradeOpen();
                                obj.Visible = false;
                            }
                        }
                        tr.Commit();
                    }
                }
                //重新生成模型
                Application.DocumentManager.MdiActiveDocument.Editor.Regen();
                //创建截图目录
                var dir = HeatSourceLayoutApp.CurrentDirectory + "\\tmp\\";
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                //截图
                Bitmap pic = null;
                if (Crop)
                {
                    pic = ScreenshotUtil.CreateScreenShot(rect);
                }
                else
                {
                    pic = ScreenshotUtil.CreateScreenShot();
                }
                if (pic != null)
                {
                    var i       = solutions.IndexOf(i_solution);
                    var outFile = HeatSourceLayoutApp.CurrentDirectory + "\\tmp\\" + (i + ".jpg");
                    pic.Save(outFile, GetFormat(outFile));
                }
                //完成一个更新一下进度条
                for (int i = number_display; i < number_display + len; i++)
                {
                    System.Threading.Thread.Sleep(5);
                    pm.MeterProgress();
                    System.Windows.Forms.Application.DoEvents();
                }
                number_display = number_display + len;
                //重新显示云线
                using (DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
                {
                    using (Transaction tr = doc.Database.TransactionManager.StartTransaction())
                    {
                        foreach (var district in i_solution.Districts)
                        {
                            Entity obj = (Entity)(tr.GetObject(district.Value.BaseObjectId, OpenMode.ForRead));
                            if (!obj.IsErased)
                            {
                                obj.UpgradeOpen();
                                obj.Visible = true;
                            }
                        }
                        tr.Commit();
                    }
                }
            }
            return(true);
        }