示例#1
0
        public async Task ScreenshotRegion()
        {
            var region = _sourcePicker.PickRegion();

            if (region == null)
            {
                return;
            }

            await SaveScreenShot(ScreenShot.Capture(region.Value));
        }
示例#2
0
        public void TearDownTest()
        {
            bool videoRecordEnabled = false;

            try
            {
                videoRecordEnabled = ConfigurationManager.AppSettings["VIDEO_RECORDING_ENABLED"].Equals("1");
                if (videoRecordEnabled)
                {
                    VideoRecorder.EndRecording();
                }

                //Prepara result block para o report
                string testResult      = String.Format("<p>{0}</p>", TestContext.CurrentContext.Result.Message);
                var    status          = TestContext.CurrentContext.Result.Outcome.Status;
                string stackTrace      = String.Format("<p>{0}</p>", TestContext.CurrentContext.Result.StackTrace);
                string screenshotBytes = ScreenShot.CaptureAsBase64EncodedString();
                string imgTag          = "<br/>" +
                                         "<img src='data:image/jpg; base64, " + screenshotBytes + "' " +
                                         "style='width:100%'>";
                string fullTestResult =
                    testResult +
                    stackTrace +
                    imgTag;

                if (ConfigurationManager.AppSettings["VIDEO_RECORDING_ENABLED"].Equals("1"))
                {
                    string videoTag = "<br/>" +
                                      "<video controls style='width:100%'> " +
                                      "<source type='video/mp4' src='data:video/mp4;base64," + VideoRecorder.GetVideoRecordedAsBase64StringAndDeleteLocalFile() + "'> " +
                                      "</video>";
                    fullTestResult +=
                        videoTag;
                }

                switch (status)
                {
                case NUnit.Framework.Interfaces.TestStatus.Failed:
                    Reporter.GetInstance().FailTest(fullTestResult);
                    Reporter.GetInstance().failedTests++;
                    break;

                default:
                    Reporter.GetInstance().PassTest(fullTestResult);
                    Reporter.GetInstance().passedTests++;
                    break;
                }

                WebDriverHooks.Driver.Quit();
            }
            catch (ConfigurationErrorsException)
            {
            }
        }
示例#3
0
        public async Task ScreenshotWindow()
        {
            var window = _sourcePicker.PickWindow();

            if (window != null)
            {
                var img = ScreenShot.Capture(window.Rectangle);

                await SaveScreenShot(img);
            }
        }
示例#4
0
        public async Task ScreenshotScreen()
        {
            var screen = _sourcePicker.PickScreen();

            if (screen != null)
            {
                var img = ScreenShot.Capture(screen.Rectangle);

                await SaveScreenShot(img);
            }
        }
示例#5
0
        public async void CaptureScreenShot(string FileName = null)
        {
            _systemTray.HideNotification();

            Bitmap bmp = null;

            var selectedVideoSource = VideoViewModel.SelectedVideoSource;
            var includeCursor       = Settings.IncludeCursor;

            switch (VideoViewModel.SelectedVideoSourceKind)
            {
            case WindowSourceProvider _:
                var hWnd = (selectedVideoSource as WindowItem)?.Window ?? Window.DesktopWindow;

                bmp = ScreenShotWindow(hWnd);
                break;

            case DeskDuplSourceProvider _:
            case ScreenSourceProvider _:
                if (selectedVideoSource is FullScreenItem)
                {
                    var hide = _mainWindow.IsVisible && Settings.UI.HideOnFullScreenShot;

                    if (hide)
                    {
                        _mainWindow.IsVisible = false;

                        // Ensure that the Window is hidden
                        await Task.Delay(300);
                    }

                    bmp = ScreenShot.Capture(includeCursor);

                    if (hide)
                    {
                        _mainWindow.IsVisible = true;
                    }
                }
                else if (selectedVideoSource is ScreenItem screen)
                {
                    bmp = screen.Capture(includeCursor);
                }

                bmp = bmp?.Transform(Settings.ScreenShots);
                break;

            case RegionSourceProvider _:
                bmp = ScreenShot.Capture(_regionProvider.SelectedRegion, includeCursor);
                bmp = bmp.Transform(Settings.ScreenShots);
                break;
            }

            SaveScreenShot(bmp, FileName);
        }
示例#6
0
    // Use this for initialization
    void Start()
    {
        scriptScreenShot = gameObject.GetComponent <ScreenShot>();
        scriptJsonFile   = gameObject.GetComponent <JSONFile>();
        scriptBB         = new List <BoundingBox>();
        objets           = GameObject.FindGameObjectsWithTag("BoundingObject");

        for (int i = 0; i < objets.Length; ++i)
        {
            scriptBB.Add(objets[i].GetComponent <BoundingBox>());
        }
    }
示例#7
0
        void HiddenForm_FormLoad(object sender, EventArgs e)
        {
            Process p = GetOtherProcess();

            if (p != null)
            {
                Close();
                return;
            }
            task = Task.Run(() => ScreenShot.Start());
            timer.Start();
        }
示例#8
0
        public void AfterScenario()
        {
            if (ScenarioContext.Current.TestError != null)
            {
                var screen = new ScreenShot();
                screen.ToTakeScreenShot();
            }

            var end = new Browser();

            end.ToFinishBrowser();
        }
示例#9
0
        //[TearDown]
        public void stoptest()
        {
            var status     = TestContext.CurrentContext.Result.Outcome.Status;
            var stacktrace = string.IsNullOrEmpty(TestContext.CurrentContext.Result.StackTrace)
                    ? ""
                    : string.Format("{0}", TestContext.CurrentContext.Result.StackTrace);
            var    errorMessage = TestContext.CurrentContext.Result.Message;
            Status logstatus;

            switch (status)
            {
            case TestStatus.Failed:
                logstatus = Status.Fail;
                string screenShotPath = ScreenShot.Capture(driver, browserstr);
                _test.Log(Status.Info, "Assertion has been Failed, Please Take a Look to Below Screenshot and StackTrace");
                _test.Log(Status.Info, stacktrace + errorMessage);
                _test.Log(Status.Info, "Snapshot below: " + _test.AddScreenCaptureFromPath(screenShotPath));
                screenShotPath = screenShotPath.Replace(@"C:\Users\admin\Desktop\Automation\Regression Scripts\18.2\", @"Z:\");
                _test.Log(Status.Info, "MailSnapshot below: " + _test.AddScreenCaptureFromPath(screenShotPath));

                break;

            case TestStatus.Inconclusive:
                logstatus = Status.Warning;
                break;

            case TestStatus.Skipped:
                logstatus = Status.Skip;
                break;

            default:
                logstatus = Status.Pass;
                break;
            }

            _test.Log(logstatus, "Test ended with " + logstatus + stacktrace);
            //  _extent.Flush();
            if (Meridian_Common.islog == true)
            {
                driver.LogoutUser(ObjectRepository.LogoutHoverLink, ObjectRepository.HoverMainLink);
            }
            else
            {
                CommonSection.Learn.Home();
                //   Driver.Instance.Navigate_to_TrainingHome();
                //  TrainingHomeobj.lnk_TrainingManagement_click(By.XPath("//a[contains(.,'Administer')]"), By.XPath("//a[contains(.,'Training Management')]"));
                //if (!driver.GetElement(By.Id("lbUserView")).Displayed)
                //{
                //    driver.Navigate().Refresh();
                //}
                //    driver.Navigate().Refresh();
            }
        }
示例#10
0
    public void Play()
    {
        float[] srcValue = AirarManager.Instance.CalculateMarkerImageVertex(cube);

        Texture2D screenShotTex = ScreenShot.GetScreenShot(arContents);

        AirarManager.Instance.ProcessColoredMapTexture(screenShotTex, srcValue, realHeight, realWidth, (resultTex) =>
        {
            drawObj = GameObject.FindGameObjectWithTag("coloring");
            drawObj.GetComponent <Renderer>().material.mainTexture = resultTex;
        });
    }
示例#11
0
    // Use this for initialization
    void Start()
    {
        SysSoftware = GameObject.Find("System");
        Camera      = GameObject.Find("Camera");
        sh          = Camera.GetComponent <ScreenShot>();
        com         = SysSoftware.GetComponent <Computer>();
        appman      = SysSoftware.GetComponent <AppMan>();

        windowID          = 57;
        ContextMenuID     = 58;
        ContextwindowRect = new Rect(2, 49, 65, 22);
    }
示例#12
0
        public SingleAssert(string message, string expected, string actual)
        {
            _message  = message;
            _expected = expected;
            _actual   = actual;

            Failed = _expected != _actual;
            if (Failed)
            {
                ScreenShot.TakeScreenShot();
            }
        }
示例#13
0
 private void Start()
 {
     if (instance == null)
     {
         instance = this;
         Object.DontDestroyOnLoad(base.transform.gameObject);
     }
     else
     {
         UnityEngine.Object.Destroy(base.transform.gameObject);
     }
 }
示例#14
0
        public ActionResult Create(ScreenShot screenshot)
        {
            if (ModelState.IsValid)
            {
                db.ScreenShots.Add(screenshot);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProjectID = new SelectList(db.Projects, "ProjectID", "alias", screenshot.ProjectID);
            return(View(screenshot));
        }
示例#15
0
        public Bitmap Capture()
        {
            var bmp = ScreenShot.Capture(Rectangle);

            using (var g = Graphics.FromImage(bmp))
                foreach (var overlay in _overlays)
                {
                    overlay.Draw(g, Rectangle.Location);
                }

            return(bmp);
        }
        /// <summary>
        /// 操作组件信息
        /// </summary>
        /// <param name="tradeMessage"></param>
        /// <returns></returns>
        public JObject HandleCompoent(JObject tradeMessage)
        {
            string itemCode = tradeMessage.GetValue("itemCode").ToString();

            string pageCode = tradeMessage.GetValue("pageCode").ToString();

            string relation = tradeMessage.GetValue("relation").ToString();

            string executeTime = "";

            bool result = true;

            logger.Info("开始操作组件");

            browserUntils = BrowserUntils.GetBrowser(transCode, pageCode);

            logger.Info("获取浏览器对象");

            if (CheckPage(transCode, pageCode) && CheckCompoent(transCode, pageCode, itemCode))
            {
                if (tradeMessage.GetValue("isscreen").ToString().Equals("Y"))
                {
                    //截图
                    ScreenShot.Shot(browserUntils.browser);
                }
                if (relation != "")
                {
                    //执行表达式相关操作
                    HandleRelationExpression(relation);
                }
                if (tradeMessage.Property("resultMap") != null && tradeMessage.GetValue("resultMap").ToString() != "")
                {
                    //处理预期结果
                    ExpectedResult expectedResult = new ExpectedResult(browserUntils);

                    result = expectedResult.CheckExpectedResult(tradeMessage);
                }

                DateTime startTime = DateTime.Now;
                ExecuteCompoent(tradeMessage);
                DateTime endTime = DateTime.Now;
                executeTime = (endTime - startTime).Milliseconds.ToString();//操作组件的时间

                tradeMessage.Add("direction", executeTime);
                tradeMessage.Add("checkResult", result);
            }
            else
            {
                Property.executeResult = false;
            }
            return(tradeMessage);
        }
示例#17
0
 public ScreenShotSQL ConvertToScreenShotSQL(ScreenShot screenshot)
 {
     return(new ScreenShotSQL()
     {
         dateCreate = ConverterHelper.ConvertDateTimeToMillisec(DateTime.Now).ToString(),
         Date = ConverterHelper.ConvertDateWithoutTimeToMillisec(DateTime.Now),
         GUID = screenshot.GUID,
         QueueCommandID = screenshot.QueueCommandID,
         ImageScreen = screenshot.ImageScreen, //(screenshot.ImageScreen == null) ? null : JsonConvertorExtention.FromJsonString<byte[]>(screenshot.ImageScreen.ToJsonString()),
         IsActive = true,
         IsSynchronized = screenshot.IsSynchronized
     });
 }
示例#18
0
文件: Class1.cs 项目: xProf81/c_pilot
        private void showEveWindow(IntPtr _hWnd)
        {
            Window.ShowWindow(_hWnd, 9);
            Window.SetFrontWindow(windowName);
            Utility.Delay(200, 300);
            Bitmap screen = ScreenShot.Create(_hWnd);

            if (screen.Height < PhysicalScreenHeight - 70)
            {
                Window.ShowWindow(_hWnd, 3);
                Utility.Delay(200, 300);
            }
        }
示例#19
0
        void UpdateBackground()
        {
            using (var bmp = ScreenShot.Capture())
            {
                var stream = new MemoryStream();
                bmp.Save(stream, ImageFormat.Png);

                stream.Seek(0, SeekOrigin.Begin);

                var decoder = new PngBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.Default);
                Background = new ImageBrush(decoder.Frames[0]);
            }
        }
示例#20
0
 void Update()
 {
     if (Input.GetKeyUp(KeyCode.F4))
     {
         ScreenShot.CaptureScreen("ScreenShot",
                                  System.DateTime.Now.Year.ToString() +
                                  System.DateTime.Now.Month.ToString() +
                                  System.DateTime.Now.Day.ToString() +
                                  System.DateTime.Now.Hour.ToString() +
                                  System.DateTime.Now.Minute.ToString() +
                                  System.DateTime.Now.Second.ToString(),
                                  m_ScreenShotSuperSize);
     }
 }
        public void GivenIAmNowOnThePageIShouldCompleteTheChallenge(string challengeTitle)
        {
            switch (challengeTitle)
            {
            case "Challenge 1":
                ChallengeOne one = new ChallengeOne(driver);
                one.fillCorrectTextBox();
                one.clickSubmit();
                TestReport.Test().Pass("Challenge 1 successfull!");
                break;

            case "Challenge 2":
                ChallengeTwo two = new ChallengeTwo(driver);
                two.inputText();
                two.clickSubmit();
                TestReport.Test().Pass("Challenge 2 successfull!");
                break;

            case "Challenge 3":
                ChallengeThree three = new ChallengeThree(driver);
                three.InputText();
                three.clickSubmit();
                TestReport.Test().Pass("Challenge 3 successfull!");
                break;

            case "Challenge 4":
                ChallengeFour four = new ChallengeFour(driver);
                four.sortNumbers();
                four.clickSubmit();
                TestReport.Test().Pass("Challenge 4 successfull!");
                break;

            case "Challenge 5":
                ChallengeFive five = new ChallengeFive(driver);
                five.clickSubmit();
                TestReport.Test().Pass("Challenge 5 successfull!");
                break;

            case "Complete!":
                ChallengeFinish finish = new ChallengeFinish(driver);
                finish.verifyPageFinsihTitle(challengeTitle);
                TestReport.Test().Pass("Challenge Complete successfull!");
                break;

            default:
                TestReport.Test().Fail("Failure! The attemped Challenge has failed.");
                ScreenShot.takeScreenshot("FeatureFileError_" + ScenarioContext.Current.ScenarioInfo.Title, driver);
                throw new ArgumentException("Invalid page title entered");
            }
        }
示例#22
0
        /// <inheritdoc />
        public void TakeVisibleScreenShot(string name)
        {
            ScreenShotName = $"{name}.png";

            try
            {
                ScreenShot = Driver.ScreenShot;
                ScreenShot.SaveAsFile(ScreenShotPath, ScreenshotImageFormat.Png);
            }
            catch (Exception e)
            {
                LogManager.Error(e.Message);
            }
        }
示例#23
0
        /** Note Handling  **/
        /********************/

        // Saves all screenshots in files
        private void ScreenShot_Click(object sender, RoutedEventArgs e)
        {
            Logger.Record("[ScreenShot_Click]: Capturing screen", "SMWidget", "info");
            var edit   = Control.ModifierKeys == Keys.Shift;
            var direct = Control.ModifierKeys == Keys.Control;

            if (edit || !direct)
            {
                WindowState = WindowState.Minimized;
            }
            Image imgOut;
            var   ss = new ScreenShot();

            if (!direct && !edit)
            {
                imgOut = ss.CaptureSnippet();
            }
            else
            {
                imgOut = ss.CaptureScreenShot();
            }
            if (ss.Canceled)
            {
                if (edit || !direct)
                {
                    WindowState = WindowState.Normal;
                }
                Logger.Record("[ScreenShot_Click]: Cancelled screenshot", "SMWidget", "info");
                return;
            }
            AddScreenshot2Note(imgOut);
            Logger.Record("[ScreenShot_Click]: Captured " + _screenshotName + ", edit: " + edit, "SMWidget", "info");
            if (edit)
            {
                var paint = new Process
                {
                    StartInfo =
                    {
                        FileName  = "mspaint.exe",
                        Arguments = "\"" + _currentSession.WorkingDir + _screenshotName + "\""
                    }
                };
                paint.Start();
            }
            if (edit || !direct)
            {
                WindowState = WindowState.Normal;
            }
        }
示例#24
0
    //-----------------------------------------------------------------------------------
    // Read the ScreenShots
    //-----------------------------------------------------------------------------------

    protected List <ScreenShot> readScreenshots(XPathNavigator nav)
    {
        List <ScreenShot> list = new List <ScreenShot>();
        XPathNodeIterator NodeIter;

        NodeIter = nav.Select("/project/screenShots/screenShot");
        while (NodeIter.MoveNext())
        {
            ScreenShot s = new ScreenShot();
            s.description = NodeIter.Current.SelectSingleNode("description").Value;
            s.imageUrl    = NodeIter.Current.SelectSingleNode("imageUrl").Value;
            list.Add(s);
        }
        return(list);
    }
示例#25
0
        public static void ClickLogin()
        {
            GenericMethods.ButtonClick(GlobalDefinition.driver, "XPath", "//*[@id='loginbutton']");
            var ScreenshotPath = ScreenShot.SaveScreenshot(GlobalDefinition.driver, "Home Page");

            try
            {
                Assert.AreEqual("(1) Facebook", GlobalDefinition.driver.Title);
                Console.WriteLine("Login Successful");
            }
            catch
            {
                Console.WriteLine("Login Failure");
            }
        }
示例#26
0
        /// <summary>
        /// Method to verify that the automation script is on the right page
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public bool verifyTitle(string text, By title)
        {
            string match = returnText(title, 20);

            if (text == match)
            {
                return(true);
            }
            else
            {
                TestReport.Test().Fail("Unable to find text!");
                ScreenShot.takeScreenshot("VerifyTitleError" + ScenarioContext.Current.ScenarioInfo + Date, d);
                throw new Exception("Unable to find text!");
            }
        }
示例#27
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            ThemeUtil.Apply(this);
            MainForm_ForeColorChanged(null, null);

            // 干掉按钮边框
            btnScreenshot.NoBorder();

            Height = 20;
            Width  = 88;
            Init();

            // 初始化截图窗口
            ScreenShot.Init();
        }
示例#28
0
        private void CapturaPantalla()
        {
            Rectangle bounds  = Screen.GetBounds(Screen.GetBounds(Point.Empty));
            string    fi      = ".png";
            Size      curSize = default(Size);
            Point     curPos  = default(Point);

            DateTime Hoy        = DateTime.Now;
            string   archivo    = Hoy.ToString("yyyyMMddHHmmss") + "-SS";
            string   Path       = ConfigurationManager.AppSettings["Path"].ToString();
            string   ScreenPath = $@"{Path}{archivo}.png";

            ScreenShot.CaptureImage(true, curSize, curPos,
                                    Point.Empty, Point.Empty, bounds, ScreenPath, fi);
        }
示例#29
0
        private ScreenShot _takeScreenShot(CommandDTO cmdExec)
        {
            var returnValue = new ScreenShot();

            byte[] screenshotAsByteArray = null;
            if (cmdExec.ScreenShot.Take == true)
            {
                Screenshot ss = ((ITakesScreenshot)WebDriver).GetScreenshot();
                screenshotAsByteArray = ss.AsByteArray;
            }
            returnValue.Name = cmdExec.ScreenShot.Name;
            returnValue.Img  = screenshotAsByteArray;
            returnValue.Take = cmdExec.ScreenShot.Take;
            return(returnValue);
        }
示例#30
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            ThemeUtil.Apply(this);
            UpdateShotButton(ForeColor);

            // 干掉按钮边框
            btnScreenshot.NoBorder();

            Height = Util.ScaleY(20);
            Width  = Util.ScaleX(88);
            Init();

            // 初始化截图窗口
            ScreenShot.Init();
        }
示例#31
0
        private void InitializeScreen()
        {
            screenShot = ScreenShot.CreateScreenShot();
            if (screenShot.ScreenImage != null)
            {
                IntPtr hBitmap = screenShot.ScreenImage.GetHbitmap();
                try
                {
                    ImageBrush brush = new System.Windows.Media.ImageBrush(
                        System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                            hBitmap,
                            IntPtr.Zero,
                            System.Windows.Int32Rect.Empty,
                            System.Windows.Media.Imaging.BitmapSizeOptions.FromWidthAndHeight(screenShot.ScreenImage.Width, screenShot.ScreenImage.Height)
                        )
                    );
                    if (brush != null)
                    {
                        this.Background = brush;
                    }
                }
                catch { }
                finally
                {
                    DeleteObject(hBitmap);
                }

                //this is better than setting the windows mode as maximized,
                //in the latter case the window size is ridiculously bigger than the screen size
                if (screenShot.Width > 0 && screenShot.Height > 0)
                {
                    this.Width = screenShot.Width;
                    this.Height = screenShot.Height;
                }
            }
        }
示例#32
0
 // Use this for initialization
 void Awake()
 {
     script = this;
 }
示例#33
0
    // Use this for initialization
    IEnumerator Start()
    {
        if (cam == null) {
                        cam = Camera.main;
                }

                if (onScreenDrawingComp == null) {
                        onScreenDrawingComp = cam.GetComponent<OnScreenDrawing> ();
                }

                if (menuWindowAnimator == null) {
                        menuWindowAnimator = GameObject.Find ("menu-window (Drawing Level)").GetComponent<Animator> ();
                }

                if (blakScreenAnimator == null) {
                        blakScreenAnimator = GameObject.Find ("black-screen").GetComponent<Animator> ();
                }

                if (drawResizerBackgroundAnimator == null) {
                        drawResizerBackgroundAnimator = GameObject.Find ("draw-resizer-background (Drawing Level)").GetComponent<Animator> ();
                }

                if (toolsAnimator == null) {
                        toolsAnimator = GameObject.Find ("Tools").GetComponent<Animator> ();
                }

                if (middleCam == null) {
                        middleCam = GameObject.FindGameObjectWithTag ("MiddleCam").GetComponent<Camera> ();
                }

                screenShotComp = GetComponent<ScreenShot> ();
                CreateShape ();
                CheckNextPreviousAlpha ();
                CheckMusicIcon (SFX.instance.audioSources [0], GameObject.Find ("music_on (Drawing Level)"));
                CheckSoundIcon (SFX.instance.audioSources [1], GameObject.Find ("sound_on (Drawing Level)"));
                yield return new WaitForSeconds (0.5f);
                DrawingColor.isReady = true;
                yield return new WaitForSeconds (1.5f);
    }
示例#34
0
 private void Window_Closed(object sender, EventArgs e)
 {
     screenShot.Dispose();
     screenShot = null;
     App.Instance.TryExit();
 }