/// <summary>
        /// Capture and attach screenshot on test failure.
        /// </summary>
        public static void Attach()
        {
            //Check if prereq passed and the file name/path setup correctly.
            string screenshotName = MobileTestContext.Get <string>(Constants.ScreenshotFileKey, false);

            if (string.IsNullOrEmpty(screenshotName))
            {
                TestLogs.Write("No screenshot file exists, no screenshot will be attached.");
                return;
            }
            CaptureScreenshot(screenshotName);

            if (!File.Exists(screenshotName))
            {
                TestLogs.Write("No screenshot file exists, no screenshot will be attached.");
                return;
            }
            TestContext.AddTestAttachment(MobileTestContext.Get <string>(Constants.ScreenshotFileKey), $"Error screenshot");
        }
Example #2
0
            private void AfterInvocation(IInvocation invocation)
            {
                string logcontent = $"---------Script Call Successful =>[{invocation.Method.DeclaringType}.{invocation.Method.Name}] ";

                TestLogs.Write(logcontent + "---------");
            }