public static void TakeScreenshot()
        {
            var now = DateTime.Now;

            _screenshots.Add(new Screenshot(now));
            ScreenshotTaker.TakeScreenshot(Output.GetScreenshotsPath(ReportHelper.Configuration.LocalOutputPath), now);
        }
Ejemplo n.º 2
0
        private void TakeScreenshot()
        {
            //TODO: investigate: Taking screenshots quickly makes application fail for unknown reason with global keys. problem is not reproduced with doing other stuff.
            //TODO: other library?
            lock (_syncObject)
            {
                if (DateTime.Now - _takingScreenshotDate < new TimeSpan(0, 0, 0, 3))
                {
                    return;
                }

                _takingScreenshotDate = DateTime.Now;
            }

            string fileName = ApplicationDirectories.GenerateOutputScreenshotFileName();

            using (var screenshot = ScreenshotTaker.TakeScreenshot())
            {
                screenshot.Save(fileName);
            }

            try
            {
                Process.Start(fileName);
            }
            catch
            {
                Process.Start("explorer.exe", @"/select, " + fileName);
            }
        }
Ejemplo n.º 3
0
        public void TeamIsDisplay()
        {
            try
            {
                HomeForm home = new HomeForm();
                Assert.AreEqual("2018 FIFA World Cup Russia™".ToLower(), home.Header.GetTitleText.ToLower());
                home.GoToPlayersForm();

                PlayersForm players = new PlayersForm();
                players.WaitForLoadingPage();
                Assert.IsTrue(players.IsFormTitleDisplay);

                PlayerBrowserSearchByPositionForm playerBrowser     = players.SelectPlayer();
                PlayerBrowserSearchByTeamForm     playerBrowserTeam = playerBrowser.SelectTeam();
                playerBrowserTeam.WaitForLoadingPage();
                Assert.IsTrue(playerBrowserTeam.IsFormTitleDisplay);
                playerBrowserTeam.ClickTeam(TEAM_NAME);
                playerBrowserTeam.WaitForLoadingPage();
                Assert.IsTrue(playerBrowserTeam.SelectedTeamIsDisplayed(TEAM_NAME));
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                ScreenshotTaker taker = new ScreenshotTaker();
                taker.MakeScreen();
                taker.PrintScreenshotsTo();
                Assert.Fail();
            }
        }
Ejemplo n.º 4
0
        public void TakeScreenshot(string fileName = null)
        {
            var screenshot = ScreenshotTaker.GetScreenshot();

            if (!Directory.Exists(_screenShotPath))
            {
                Directory.CreateDirectory(_screenShotPath);
            }

            var windowTitle = Browser.Title;

            fileName = fileName ?? string.Format("{0}{1}.png", windowTitle, DateTime.Now.ToFileTime()).Replace(':', '.');
            var outputPath = Path.Combine(_screenShotPath, fileName);

            var pathChars = Path.GetInvalidPathChars();

            var stringBuilder = new StringBuilder(outputPath);

            foreach (var item in pathChars)
            {
                stringBuilder.Replace(item, '.');
            }

            var screenShotPath = stringBuilder.ToString();

            screenshot.SaveAsFile(screenShotPath, ImageFormat.Png);
        }
Ejemplo n.º 5
0
 private void AttachMapiScreenshotIfRequired(Mapi mapi)
 {
     if (_reportInfo.ScreenshotAvailable)
     {
         mapi.Attach(ScreenshotTaker.GetImageAsFile(_reportInfo.ScreenshotImage));
     }
 }
Ejemplo n.º 6
0
        public static bool DoSingleTick(TickManager __instance)
        {
            //RimThreaded.currentInstance = __instance;

            if (!DebugSettings.fastEcology)
            {
                __instance.ticksGameInt++;
            }
            else
            {
                __instance.ticksGameInt += 2000;
            }
            Shader.SetGlobalFloat(ShaderPropertyIDs.GameSeconds, __instance.TicksGame.TicksToSeconds());

            RimThreaded.MainThreadWaitLoop(__instance);

            if (DebugViewSettings.logHourlyScreenshot && Find.TickManager.TicksGame >= __instance.lastAutoScreenshot + 2500)
            {
                ScreenshotTaker.QueueSilentScreenshot();
                __instance.lastAutoScreenshot = Find.TickManager.TicksGame / 2500 * 2500;
            }

            Debug.developerConsoleVisible = false;
            return(false);
        }
    public void VideoScreenshotCapture()
    {
        //Debug.Log("agors_: VideoScreenshotCapture");
        string photoName = "";

        ScreenshotTaker.CaptureScreenshot(photoName, ShowSpriteFromPhoto);
    }
        protected void InitTempManager()
        {
            //			Debug.Log ("InitTempManager");

            if (m_ScreenshotTaker != null)
            {
                if (!Application.isPlaying)
                {
                    m_ScreenshotTaker.Reset();
                }
                return;
            }

            if (m_SafeAreaInstance != null)
            {
                GameObject.DestroyImmediate(m_SafeAreaInstance);
            }


            GameObject obj = new GameObject();

            obj.name = "Temporary screenshot manager - remove if still exists in scene in edit mode.";

            // Create the screenshot taker
            m_ScreenshotTaker = obj.AddComponent <ScreenshotTaker>();
#if (UNITY_EDITOR) && (!UNITY_5_4_OR_NEWER)
            m_ScreenshotTaker.m_ForceLayoutPreservation = false;
#endif
            m_ScreenshotTaker.m_GameViewResizingWaitingMode   = m_ConfigAsset.m_Config.m_GameViewResizingWaitingMode;
            m_ScreenshotTaker.m_GameViewResizingWaitingFrames = m_ConfigAsset.m_Config.m_ResizingWaitingFrames;
            m_ScreenshotTaker.m_GameViewResizingWaitingTime   = m_ConfigAsset.m_Config.m_ResizingWaitingTime;
        }
Ejemplo n.º 9
0
        public void AttachFiles(IAttach attacher)
        {
            var files = new List <string>();

            if (_config.FilesToAttach.Length > 0)
            {
                files.AddRange(_config.FilesToAttach);
            }
            if (_config.ScreenshotAvailable)
            {
                files.Add(ScreenshotTaker.GetImageAsFile(_config.ScreenshotImage));
            }

            var filesThatExist = files.Where(f => File.Exists(f)).ToList();

            // attach external zip files separately - admittedly weak detection using just file extension
            filesThatExist.Where(f => f.EndsWith(ZIP)).ToList().ForEach(attacher.Attach);

            // now zip & attach all specified files (ie config FilesToAttach) plus screenshot, if taken
            var filesToZip = filesThatExist.Where(f => !f.EndsWith(ZIP)).ToList();

            if (filesToZip.Any())
            {
                var zipFile = File.TempFile(_config.AttachmentFilename);
                Zipper.Zip(zipFile, filesToZip);
                attacher.Attach(zipFile);
            }
        }
Ejemplo n.º 10
0
 private void AttachSmtpScreenshotIfRequired(MailMessage mailMessage)
 {
     if (_reportInfo.ScreenshotAvailable)
     {
         mailMessage.Attachments.Add(new Attachment(ScreenshotTaker.GetImageAsFile(_reportInfo.ScreenshotImage),
                                                    ScreenshotTaker.ScreenshotMimeType));
     }
 }
Ejemplo n.º 11
0
 public void AfterScenario()
 {
     if (ScenarioContext.Current.TestError != null)
     {
         ScreenshotTaker.Take();
     }
     WebDriver.DevastateDriver();
 }
 public NMZPointsScreenReader()
 {
     ScreenShotTaker      = new ScreenshotTaker();
     NmzPointsImageFinder = new NMZPointsImageFinder();
     ImageFilterer        = new ImageFilterer();
     Separator            = new OpticalNumberSeparator();
     OCR = new OpticalNumberRecognizer();
 }
Ejemplo n.º 13
0
    IEnumerator DoScreenshot()
    {
        yield return(new WaitForEndOfFrame());

        string    path    = ScreenshotTaker.TakeScreenshot(savePath);
        Texture2D texture = ScreenshotTaker.TakeScreenshotTexture2D();

        TemplateGameManager.Instance.debugPopups.ShowPopup($"Capture screenshot to {path}\nPress {openScreenshotFolderKey} to open folder with it", texture);
    }
        public void TestInitialize()
        {
            log.Debug("***** TEST STARTED *****");
            log.Debug("***** TEST STARTED *****");
            Reporter.AddTestCaseMetadataToHtmlReport(TestContext);
            var factory = new AutomationResources.WebDriverFactory();

            Driver          = factory.Create(BrowserType.CHROME);
            ScreenshotTaker = new ScreenshotTaker(Driver, TestContext);
        }
Ejemplo n.º 15
0
 public void SetupBeforeEveryTestMethod()
 {
     Logger.Debug("*************************************** TEST STARTED");
     Logger.Debug(GetType().FullName + " started a method Initialize");
     //Reporter.StartReporter();
     Reporter.AddTestCaseMetadataToHtmlReport(TestContext);
     Driver = new WebDriverFactory().Create(BrowserType.Chrome);
     Driver.Manage().Window.Maximize();
     ScreenshotTaker = new ScreenshotTaker(Driver, TestContext);
 }
Ejemplo n.º 16
0
 public void SetupBeforeEverySingleTest()
 {
     Logger.Debug("*** TEST STARTED ***");
     ReporterHelper.AddTestCaseMetadataToHtmlReports(TestContext.CurrentContext);
     Driver = new WebDriverFactory().Create(BrowserType.Chrome);
     Driver.Manage().Window.Maximize();
     ScreenshotTaker = new ScreenshotTaker(Driver);
     InsightsPage    = new InsightsPage(Driver);
     InsightsPage.GoTo();
 }
Ejemplo n.º 17
0
 public void BaseSetup()
 {
     Logger.Debug("*************************** TEST STARTED");
     Logger.Debug("*************************** TEST STARTED");
     this.TestContext = TestContext.CurrentContext;
     Reporter.AddTestCaseMetadataToHtmlReport(this.TestContext);
     this.Driver = WebDriverFactory.CreateSauceDriver(this.sauceConfigurations);
     this.Driver.Manage().Window.Maximize();
     this.ScreenshotTaker = new ScreenshotTaker(this.Driver, this.TestContext);
 }
Ejemplo n.º 18
0
    private void OnGUI()
    {
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

        _list = _list ?? ScreenShooterConfigList.Create(data.screenshoots, OnMenuItemAdd);
        _list.DoLayoutList();

        GUI.enabled = true;
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        if (data.outputFolder == "-----")
        {
            data.outputFolder = ScreenshotTaker.GetDefaultScreenshotPath();
        }
        data.outputFolder = PathField("Save to:", data.outputFolder);


        EditorGUILayout.Space();
        EditorGUILayout.Space();
        if (GUILayout.Button(ScreenshotTaker.IsPaused ? "Play" : "Pause"))
        {
            ScreenshotTaker.Pause();
        }
        if (GUILayout.Button("Next Frame"))
        {
            ScreenshotTaker.WaitOneFrame();
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        GUI.enabled = ScreenshotTakerEditor.isScreenshotQueueEmpty;
        if (GUILayout.Button("Capture Screenshots Series"))
        {
            ScreenshotTakerEditor.CaptureScreenshootQueueAllLanguages(data.screenshoots, data.outputFolder);
        }

        if (GUILayout.Button("Take Game View Screenshot"))
        {
            ScreenshotTaker.TakeScreenshot(data.outputFolder);
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        if (GUILayout.Button("Add all sizes to Game window sizes selector"))
        {
            ScreenshotTakerEditor.AddAllSizes(data.screenshoots);
        }
        if (GUILayout.Button("Clear all Game window sizes selector"))
        {
            ScreenshotTakerEditor.ClearAllSizes();
        }

        GUI.enabled = true;
        EditorGUILayout.EndScrollView();
    }
Ejemplo n.º 19
0
        public void SetupForEverySingleTestMethod()
        {
            Logger.Debug("*************************************** TEST STARTED");
            Logger.Debug("*************************************** TEST STARTED");
            Reporter.AddTestCaseMetadataToHtmlReport(TestContext);
            var factory = new WebDriverFactory();

            Driver = factory.Create(BrowserType.Chrome);
            Driver.Manage().Window.Maximize();
            ScreenshotTaker = new ScreenshotTaker(Driver, TestContext);
        }
Ejemplo n.º 20
0
        private void AddMapiAttachments(Mapi mapi)
        {
            if (_reportInfo.ScreenshotAvailable)
            {
                mapi.Attach(ScreenshotTaker.GetImageAsFile(_reportInfo.ScreenshotImage));
            }

            foreach (string file in _reportInfo.FilesToAttach)
            {
                mapi.Attach(file);
            }
        }
Ejemplo n.º 21
0
 private void TakeScreenshotForTestFailure()
 {
     if (ScreenshotTaker != null)
     {
         ScreenshotTaker.CreateScreenshotIfTestFailed();
         ReporterHelper.ReportTestOutcome(ScreenshotTaker.ScreenshotFilePath);
     }
     else
     {
         ReporterHelper.ReportTestOutcome("");
     }
 }
Ejemplo n.º 22
0
        public void InitializeBeforeEveryTestMethod()
        {
            Logger.Info(string.Format("********************************** {0} Started ***********************************", TestContext.TestName));
            Reporter.AddTestCaseMetadataToHtmlReport(TestContext);

            var factory = new WebDriverFactory();

            Driver = factory.Create(BrowserType.Chrome);
            Driver.Manage().Window.Maximize();
            Driver.Manage().Cookies.DeleteAllCookies();

            ScreenshotTaker = new ScreenshotTaker(Driver, TestContext);
        }
Ejemplo n.º 23
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         //Debug.Log("agora_: ScreenShoot Activate");
     }
     else
     {
         Destroy(gameObject);
         return;
     }
 }
        public void Can_Take_Screenshot()
        {
            var screenshot = ScreenshotTaker.TakeScreenShot();

            if (ExceptionReporter.IsRunningMono())
            {
                Assert.That(screenshot, Is.Null);
            }
            else
            {
                Assert.IsNotNull(screenshot);
            }
        }
Ejemplo n.º 25
0
    private static void CaptureScreenshotWithUI(ScreenshotData data)
    {
        RenderTexture temp = RenderTexture.active;

        RenderTexture renderTex  = (RenderTexture)GameView.FetchField("m_TargetTexture");
        Texture2D     screenshot = null;

        int width  = renderTex.width;
        int height = renderTex.height;

        try {
            RenderTexture.active = renderTex;

            screenshot = new Texture2D(width, height, TextureFormat.RGB24, false);
            screenshot.ReadPixels(new Rect(0, 0, width, height), 0, 0, false);

            if (SystemInfo.graphicsUVStartsAtTop)
            {
                Color32[] pixels = screenshot.GetPixels32();
                for (int i = 0; i < height / 2; i++)
                {
                    int startIndex0 = i * width;
                    int startIndex1 = (height - i - 1) * width;
                    for (int x = 0; x < width; x++)
                    {
                        Color32 color = pixels[startIndex0 + x];
                        pixels[startIndex0 + x] = pixels[startIndex1 + x];
                        pixels[startIndex1 + x] = color;
                    }
                }

                screenshot.SetPixels32(pixels);
            }

            screenshot.Apply(false, false);

#if POLYGLOT
            File.WriteAllBytes(ScreenshotTaker.GetUniqueFilePath(width, height, data.targetCamera == ScreenshooterTargetCamera.SceneView, true, data.lang.ToString(), usedOutputFolder, "jpeg"), screenshot.EncodeToJPG(100));
#else
            File.WriteAllBytes(ScreenshotTaker.GetUniqueFilePath(width, height, data.targetCamera == ScreenshooterTargetCamera.SceneView, true, "", usedOutputFolder, "jpeg"), screenshot.EncodeToJPG(100));
#endif
        }
        finally {
            RenderTexture.active = temp;

            if (screenshot != null)
            {
                GameObject.DestroyImmediate(screenshot);
            }
        }
    }
 private void TakeScreenshotIfFailed()
 {
     try
     {
         if (!_test.IsSuccess() && _configuration.TakeScreenshotAfterTestFailed)
         {
             var now = DateTime.Now;
             _test.Screenshots.Add(new Screenshot(now));
             ScreenshotTaker.TakeScreenshot(_screenshotsPath, now);
         }
     }
     catch (Exception ex)
     {
         InternalLogs.Exception(ex, "Exception in TakeScreenshot");
     }
 }
    public static bool AllowedToUpdate = true; // set to false and then back to true by SaveManager.LoadAll to make sure circuitry doesn't run before it's finished loading.

    private void Update()
    {
        ScreenshotTaker.RunScreenshotTaking();

        if (!AllowedToUpdate)
        {
            return;
        }

        GameplayUIManager.RunGameplayUI();

        CircuitLogicUpdate.Update(); // might affect VisualStuffUpdate
        VisualStuffUpdate();         // might affect mega mesh stuff

        MeshQueueing.Update();
        RecalculateQueuedMegaMeshGroups();
    }
Ejemplo n.º 28
0
 public static bool AreEqual(object expected, object actual, bool screenshotOnFail = false)
 {
     try
     {
         Assert.AreEqual(expected, actual);
         return(true);
     }
     catch (AssertionException ex)
     {
         Console.WriteLine(ex);
         if (screenshotOnFail)
         {
             ScreenshotTaker.TakeScreenshot();
         }
         return(false);
     }
 }
Ejemplo n.º 29
0
 public static bool AreEqual(double expected, double actual, double delta, bool screenshotOnFail = false)
 {
     try
     {
         Assert.AreEqual(expected, actual, delta);
         return(true);
     }
     catch (AssertionException ex)
     {
         Console.WriteLine(ex.Message);
         if (screenshotOnFail)
         {
             ScreenshotTaker.TakeScreenshot();
         }
         return(false);
     }
 }
        protected void DestroyManager()
        {
            //			Debug.Log ("Destroy manager");

            if (m_ScreenshotTaker == null)
            {
                return;
            }

            if (Application.isPlaying)
            {
                return;
            }

            m_ScreenshotTaker.Reset();
            GameObject.DestroyImmediate(m_ScreenshotTaker.gameObject);
            m_ScreenshotTaker = null;
        }