Ejemplo n.º 1
0
 private void RunScenario(string url)
 {
     MainPage.NavigateTo(url);
     MainPage.FindAgents().NavigateToFindAgents();
     MainPage.FindAgents().SelectAgent("AgentDetails.txt");
     CaptureScreenshot.Capture(Driver.Instance, "ScenarioC_pass.png");
     MainPage.FindAgents().ChangeLanguage();
     CaptureScreenshot.Capture(Driver.Instance, "ScenarioC_pass_after_language_changed.png");
 }
Ejemplo n.º 2
0
    public byte[] WatsonScreenShot(CaptureScreenshot.ImageFormat imageFormat)
    {
        cam.cullingMask     = screenshotCullingMask;
        cam.clearFlags      = screenshotClearFlags;
        cam.backgroundColor = Color.black;

        var bytes = CaptureScreenshot.Capture(cam, imageFormat);

        cam.cullingMask     = defaultCullingMask;
        cam.clearFlags      = defaultClearFlags;
        cam.backgroundColor = defaultBackgroundColor;

        return(bytes);
    }
Ejemplo n.º 3
0
 public ActionResult CaptureScreen()
 {
     try
     {
         CaptureScreenshot.FullScreenshot();
         return(Json(new { success = true, message = "", JsonRequestBehavior.AllowGet }));
     }
     catch (Exception ex)
     {
         Common.ExceptionLog(ex.Message);
         string _log = "http://boredsilly.in/Content/Logs/" + "Log_" + DateTime.Now.ToString("dd_MM_yyyy") + ".txt";
         return(Json(new { success = false, message = ex.Message, url = _log, JsonRequestBehavior.AllowGet }));
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// To Verify that user is able to login to the application
        /// </summary>
        /// <param name="inputjson">The input json</param>
        /// <returns>Test reports</returns>
        public List <TestReportSteps> LoginToApplication(JToken inputjson)
        {
            List <TestReportSteps> listOfReport = new List <TestReportSteps>();
            int step = 0;

            try
            {
                listOfReport.Add(ReusableComponents.GenerateReportSteps("Enter username", "username", "To Verify that user is able to login to the application", step));
                ReusableComponents.SendKeys(driver, "XPath", jObject["username"].ToString(), inputjson["username"].ToString());
                listOfReport[step].actualResultFail = "";
                step++;

                listOfReport.Add(ReusableComponents.GenerateReportSteps("Enter password", "password", "To Verify that user is able to login to the application", step));
                ReusableComponents.SendKeys(driver, "XPath", jObject["password"].ToString(), inputjson["password"].ToString());
                listOfReport[step].actualResultFail = "";
                step++;

                listOfReport.Add(ReusableComponents.GenerateReportSteps("Capture screenshot", "details", "To Verify that user is able to login to the application", step));
                screenshotList.Add(CaptureScreenshot.TakeSingleSnapShot(driver, "details"));;
                listOfReport[step].actualResultFail = "";
                step++;

                listOfReport.Add(ReusableComponents.GenerateReportSteps("Click loginButton", "", "To Verify that user is able to login to the application", step));
                ReusableComponents.Click(driver, "XPath", jObject["loginButton"].ToString());
                listOfReport[step].actualResultFail = "";
                step++;

                listOfReport.Add(ReusableComponents.GenerateReportSteps("Wait until verifyLogin is visible", "", "To Verify that user is able to login to the application", step));
                ReusableComponents.WaitUntilElementVisible(driver, "XPath", jObject["verifyLogin"].ToString());
                listOfReport[step].actualResultFail = "";
                step++;

                listOfReport.Add(ReusableComponents.GenerateReportSteps("Wait until loader is invisible", "", "To Verify that user is able to login to the application", step));
                ReusableComponents.WaitUntilElementInvisible(driver, "XPath", jObject["loader"].ToString());
                listOfReport[step].actualResultFail = "";
                step++;

                listOfReport.Add(ReusableComponents.GenerateReportSteps("Capture screenshot", "verifyLogin", "To Verify that user is able to login to the application", step));
                screenshotList.Add(CaptureScreenshot.TakeSingleSnapShot(driver, "verifyLogin"));;
                listOfReport[step].actualResultFail = "";
                step++;
            }
            catch (Exception e)
            {
                Console.WriteLine("LoginToApplication failed: " + e);
                listOfReport[step - 1].SetActualResultFail("Failed");
            }
            return(listOfReport);
        }
Ejemplo n.º 5
0
 public void RunTest()
 {
     foreach (var run in Runs)
     {
         try
         {
             RunScenario(run.Url);
         }
         catch (Exception e)
         {
             CaptureScreenshot.Capture(Driver.Instance, "ScenarioB_fail.png");
             Assert.Fail(e.Message);
         }
     }
 }
Ejemplo n.º 6
0
    private void Start()
    {
        SetLayerForChildren(displayParent);
        var cam = Camera.main;

        // Set a mask to only draw only elements in this layer. e.g., capture your player with a transparent background.
        cam.cullingMask = LayerMask.GetMask("Player");

        string filename = string.Format("Screenshots/capture_{0}.png", DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss-fff"));

        if (UseSimple)
        {
            CaptureScreenshot.SimpleCaptureTransparentScreenshot(cam, width, height, filename);
        }
        else
        {
            CaptureScreenshot.CaptureTransparentScreenshot(cam, width, height, filename);
        }
    }
Ejemplo n.º 7
0
    private void Update()
    {
        var space = Input.GetKeyDown(KeyCode.Space);
        var stop  = Input.GetKeyDown(KeyCode.Escape);

        if (space)
        {
            Initialize();
        }

        if (running)
        {
            if (frameCount > howMany || stop)
            {
                Debug.Log("Capture end");
                running        = false;
                Time.timeScale = 1;
            }

            string filename = Path.Combine(folderPath, $"{index++}.png");
            CaptureScreenshot.CaptureTransparentScreenshot(Camera.main, Screen.width, Screen.height, filename);
            frameCount++;
        }
    }
Ejemplo n.º 8
0
        internal static async Task CaptureScreenshotAsync([NotNull] CaptureScreenshot srv)
        {
            if (Settings.ScreenCaptureManager == null)
            {
                srv.Response.Success = false;
                srv.Response.Message = "No screenshot manager has been set for this platform";
                return;
            }

            string     errorMessage = null;
            Screenshot ss           = null;
            Pose?      pose         = null;

            using (SemaphoreSlim signal = new SemaphoreSlim(0))
            {
                GameThread.Post(async() =>
                {
                    try
                    {
                        var assetHolder = UnityEngine.Resources
                                          .Load <GameObject>("App Asset Holder")
                                          .GetComponent <AppAssetHolder>();
                        AudioSource.PlayClipAtPoint(assetHolder.Screenshot, Settings.MainCamera.transform.position);

                        ss   = await Settings.ScreenCaptureManager.CaptureColorAsync();
                        pose = ss != null
                            ? TfListener.RelativePoseToFixedFrame(ss.CameraPose).Unity2RosPose().ToCameraFrame()
                            : (Pose?)null;
                    }
                    catch (Exception e)
                    {
                        errorMessage = e.Message;
                    }
                    finally
                    {
                        signal.Release();
                    }
                });

                if (!await signal.WaitAsync(DefaultTimeoutInMs))
                {
                    Logger.Error("ControllerService: Unexpected timeout in CaptureScreenshotAsync");
                    srv.Response.Success = false;
                    srv.Response.Message = "Request timed out";
                    return;
                }
            }

            if (errorMessage != null)
            {
                srv.Response.Success = false;
                srv.Response.Message = errorMessage;
                return;
            }

            if (ss == null)
            {
                srv.Response.Success = false;
                srv.Response.Message = "Captured failed for unknown reason";
                return;
            }

            srv.Response.Success    = true;
            srv.Response.Width      = ss.Width;
            srv.Response.Height     = ss.Height;
            srv.Response.Bpp        = ss.Bpp;
            srv.Response.Header     = (screenshotSeq++, ss.Timestamp, TfListener.FixedFrameId);
            srv.Response.Intrinsics = ss.Intrinsic.ToArray();
            srv.Response.Pose       = pose ?? Pose.Identity;
            srv.Response.Data       = await CompressAsync(ss);
        }
Ejemplo n.º 9
0
        /// <summary>Logs the specified error.</summary>
        /// <param name="error">The error to log.</param>
        public override void LogError(string error)
        {
            // check all properties have been set
            if (string.IsNullOrEmpty(EmailFrom))
            {
                throw new ArgumentException("EmailFrom has not been set");
            }
            if (string.IsNullOrEmpty(EmailTo))
            {
                throw new ArgumentException("EmailTo has not been set");
            }
            if (string.IsNullOrEmpty(EmailServer))
            {
                throw new ArgumentException("EmailServer has not been set");
            }

            #region 163
            //EmailFrom = "*****@*****.**";
            //EmailTo = "*****@*****.**";
            //EmailServer = "smtp.163.com";
            //string userName="******";
            //string psw="songjz!&(";
            //int portNum=25;
            //bool enableSSL=false;
            #endregion
            #region sina
            EmailFrom   = "*****@*****.**";
            EmailTo     = "*****@*****.**";
            EmailServer = "smtp.sina.com";
            string userName  = "******";
            string psw       = "zhonglin";
            int    portNum   = 25;
            bool   enableSSL = false;
            #endregion
            #region 126
            //EmailFrom = "*****@*****.**";
            //EmailTo = "*****@*****.**";
            //EmailServer = "smtp.126.com";
            //string userName = "******";
            //string psw = "zhonglin";
            //int portNum = 25;
            //bool enableSSL = false;
            #endregion
            #region gmail
            //EmailFrom = "*****@*****.**";
            //EmailTo = "*****@*****.**";
            //EmailServer = "smtp.gmail.com";
            //string userName = "******";
            //string psw = "gd&#*()%";
            //int portNum = 465;
            //bool enableSSL = true;
            #endregion

            MailMessage message = new MailMessage(EmailFrom, EmailTo, "CANOpenStudio Unhandled Exception Report", error);
            // message.To.Add()
            string filename = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\screen_Error.jpg";
            bool   again    = false;
            if (System.IO.File.Exists(filename))
            {
                try
                {
                    message.Attachments.Add(new Attachment(filename));
                }
                catch (Exception)
                {
                    again = true;
                }
            }
            if (again)
            {
                filename = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments) + "\\Desktop_screen_Error.jpg";
                BitmapSource      bs      = CaptureScreenshot.Capture(new Rect(0, 0, SystemParameters.MaximizedPrimaryScreenWidth, SystemParameters.MaximizedPrimaryScreenHeight));
                FileStream        stream1 = new FileStream(filename, FileMode.Create);
                JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                encoder.QualityLevel = 80;
                encoder.Frames.Add(BitmapFrame.Create(bs));
                //encoder.Save(stream1);
                message.Attachments.Add(new Attachment(stream1, "Desktop_screen_Error.jpg"));
            }



            message.IsBodyHtml = false;
            message.Priority   = MailPriority.High;

            //http://help.163.com/10/1111/15/6L7HMASV00753VB8.html
            //smtp.163.com 安全类型:SSL 端口号:465 / 994 ;若安全类型选择“无”,则需将端口号修改为 25。
            SmtpClient client = new SmtpClient(EmailServer);           // 如 smtp.163.com, smtp.gmail.com
            client.Port      = portNum;                                // // Gmail 使用 465 和 587 端口
            client.EnableSsl = enableSSL;                              // 如果使用GMail,则需要设置为true
            // Add credentials if the SMTP server requires them.
            client.Credentials = new NetworkCredential(userName, psw); // CredentialCache.DefaultNetworkCredentials; //new NetworkCredential("用户名", "密码"); //



            client.SendCompleted += new SendCompletedEventHandler(SendMailCompleted);
            try
            {
                client.SendAsync(message, "错误报告");
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show("Unknown Error:\n" + "Please Send The Files:'BugReport.log,screen_Error.jpg' On The Desktop To [email protected], To Help To Improve The Function Of The Application,\nThank You Very Much!\n\n\n\n" + e.Message.ToString());
            }
        }
Ejemplo n.º 10
0
        /// <summary>Logs the specified error.</summary>
        /// <param name="error">The error to log.</param>
        public override void LogError(string error)
        {
            string filename   = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);//Path.GetDirectoryName(Application.ExecutablePath);
            string filename_S = filename + "\\screen_Error.jpg";

            filename += "\\BugReport.txt";

            List <string> data = new List <string>();

            lock (this)
            {
                BitmapSource      bs      = CaptureScreenshot.Capture(new Rect(0, 0, SystemParameters.MaximizedPrimaryScreenWidth, SystemParameters.MaximizedPrimaryScreenHeight));
                FileStream        stream1 = new FileStream(filename_S, FileMode.Create);
                JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                //encoder.FlipHorizontal = true;
                //encoder.FlipVertical = false;
                encoder.QualityLevel = 80;//The quality level of the JPEG image. The value range is 1 (lowest quality) to 100 (highest quality) inclusive.

                //encoder.Rotation = Rotation.Rotate90;
                encoder.Frames.Add(BitmapFrame.Create(bs));
                encoder.Save(stream1);
                stream1.Close();
                if (IsTruncateTheFile)
                {
                    if (File.Exists(filename))
                    {
                        using (StreamReader reader = new StreamReader(filename))
                        {
                            string line = null;
                            do
                            {
                                line = reader.ReadLine();
                                data.Add(line);
                            }while (line != null);
                        }
                    }

                    // truncate the file if it's too long
                    int writeStart = 0;
                    if (data.Count > 1000)
                    {
                        writeStart = data.Count - 1000;
                    }

                    using (StreamWriter stream = new StreamWriter(filename, false))
                    {
                        for (int i = writeStart; i < data.Count; i++)
                        {
                            stream.WriteLine(data[i]);
                        }
                        stream.Write(error);
                    }
                }
                else
                {
                    using (StreamWriter stream = new StreamWriter(filename, false))
                    {
                        stream.Write(error);
                    }
                }
            }
            ExceptionHandler.textLoggerEvent.Set();
        }