Exemplo n.º 1
0
        /// <summary>
        /// A method to take a screenshot
        /// </summary>
        /// <param name="testContext"></param>
        public static string TakeScreenshot(TestContext testContext)
        {
            string testCasePath = string.Empty;

            try
            {
                string timeStampScreenshot = DateTime.Now.ToString("yyyy-MM-dd-hhmm-ss");
                _screenshotDriver = DriverManager.GetInstance().GetDriver() as ITakesScreenshot;
                _screenshot       = _screenshotDriver.GetScreenshot();
                string screenshotDir = testContext.DeploymentDirectory + "\\Results\\Screenshots\\";

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

                testCasePath = screenshotDir + testContext.TestName + "_" + timeStampScreenshot + ".png";
                Logger.Info(string.Format("Taking Screenshot for test: '{0}'", testContext.TestName), "");
                _screenshot.SaveAsFile(testCasePath, ScreenshotImageFormat.Png);

                //TODO: Get the testContext out of this class
                testContext.AddResultFile(Path.Combine(testContext.TestDeploymentDir, testCasePath));
                testContext.AddResultFile(Path.Combine(testContext.TestDeploymentDir, "Execution.log"));
            }
            catch (Exception e)
            {
                Console.WriteLine("\n TakeIt: \n" + e);
            }
            return(Path.GetFullPath(testCasePath));
        }
        public static string CreateProjectFile(TestContext testContext, string testSpecificProjectXml)
        {
            var projectDirectory = TestUtils.CreateTestSpecificFolder(testContext);

            var sqTargetFile = TestUtils.EnsureAnalysisTargetsExists(testContext);

            File.Exists(sqTargetFile).Should().BeTrue("Test error: the SonarQube analysis targets file could not be found. Full path: {0}", sqTargetFile);
            testContext.AddResultFile(sqTargetFile);


            var template    = @"<?xml version='1.0' encoding='utf-8'?>
<Project ToolsVersion='15.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>

  <!-- Boilerplate -->
  <!-- All of these boilerplate properties can be overridden by setting the value again in the test-specific XML snippet -->
  <PropertyGroup>
    <ImportByWildcardBeforeMicrosoftCommonTargets>false</ImportByWildcardBeforeMicrosoftCommonTargets>
    <ImportByWildcardAfterMicrosoftCommonTargets>false</ImportByWildcardAfterMicrosoftCommonTargets>
    <ImportUserLocationsByWildcardBeforeMicrosoftCommonTargets>false</ImportUserLocationsByWildcardBeforeMicrosoftCommonTargets>
    <ImportUserLocationsByWildcardAfterMicrosoftCommonTargets>false</ImportUserLocationsByWildcardAfterMicrosoftCommonTargets>
    <OutputPath>bin\</OutputPath>
    <OutputType>library</OutputType>
    <ProjectGuid>ffdb93c0-2880-44c7-89a6-bbd4ddab034a</ProjectGuid>
    <Language>C#</Language>
  </PropertyGroup>

  <PropertyGroup>
    <!-- Standard values that need to be set for each/most tests -->
    <SonarQubeBuildTasksAssemblyFile>SONARSCANNER_MSBUILD_TASKS_DLL</SonarQubeBuildTasksAssemblyFile>
  </PropertyGroup>

  <!-- Test-specific data -->
  TEST_SPECIFIC_XML

  <!-- Standard boilerplate closing imports -->
  <Import Project='$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), SonarQube.Integration.targets))SonarQube.Integration.targets' />
  <Import Project='$(MSBuildToolsPath)\Microsoft.CSharp.targets' />
</Project>
";
            var projectData = template.Replace("PROJECT_DIRECTORY_PATH", projectDirectory)
                              .Replace("SONARSCANNER_MSBUILD_TASKS_DLL", typeof(WriteProjectInfoFile).Assembly.Location)
                              .Replace("TEST_SPECIFIC_XML", testSpecificProjectXml ?? "<!-- none -->");

            var projectFilePath = Path.Combine(projectDirectory, testContext.TestName + ".proj.txt");

            File.WriteAllText(projectFilePath, projectData);
            testContext.AddResultFile(projectFilePath);

            return(projectFilePath);
        }
        public void QuandoRealizarOEnvioDeUmaMensagemValida()
        {
            ContactUsPage contactPage = new ContactUsPage(driver);

            contactPage.PreencherComboAssunto("Customer service")
            .PreencherEmail("*****@*****.**")
            .PreencherNumeroPedido("12346579")
            .PreencherMensagem("Mensagem de Teste");

            test.AddResultFile(ScreenshotHelper.TiraPrint("Campos preenchidos", driver));

            textoRetornado = contactPage.ClicarEnviar()
                             .VerificarMensagemSucesso();
        }
        public void SampleFunctionalTest1()
        {
            var webAppUrl      = testContext.Properties["webAppUrl"].ToString();
            var startTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
            var endTimestamp   = startTimestamp + 60 * 10;

            while (true)
            {
                try
                {
                    driver.Navigate().GoToUrl(webAppUrl);
                    Assert.AreEqual("Home Page - My ASP.NET Application", driver.Title, "Expected title to be 'Home Page - My ASP.NET Application'");
                    break;
                }
                catch (Exception e)
                {
                    var currentTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
                    if (currentTimestamp > endTimestamp)
                    {
                        Console.Write("##vso[task.logissue type=error;]Test SampleFunctionalTest1 failed with error: " + e.ToString());
                        throw;
                    }
                    Thread.Sleep(5000);
                }
            }
            var filePath   = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()) + ".png";
            var screenshot = driver.GetScreenshot();

            screenshot.SaveAsFile(filePath);
            testContext.AddResultFile(filePath);
        }
Exemplo n.º 5
0
        public async Task VerifyFormScript <T>(string filePath,
                                               string locale, BuildFormDelegate <T> buildForm, FormOptions options, T initialState, IEnumerable <EntityRecommendation> entities,
                                               params string[] inputs)
            where T : class
        {
            var newPath = Script.NewScriptPathFor(filePath);

            File.Delete(newPath);
            var currentState = JsonConvert.DeserializeObject <T>(JsonConvert.SerializeObject(initialState));

            try
            {
                using (var stream = new StreamReader(filePath))
                    using (var container = Build(Options.Reflection))
                    {
                        Func <IDialog <object> > makeRoot = () => new FormDialog <T>(currentState, buildForm, options, entities);
                        Assert.AreEqual(locale, stream.ReadLine());
                        Assert.AreEqual(SerializeToJson(initialState), stream.ReadLine());
                        Assert.AreEqual(SerializeToJson(entities), stream.ReadLine());
                        await Script.VerifyScript(container, makeRoot, false, stream, (stack, state) =>
                        {
                            var form = ((FormDialog <T>)stack.Frames[0].Target);
                            Assert.AreEqual(state, SerializeToJson(form.State));
                        }, inputs, locale);
                    }
            }
            catch (Exception)
            {
                // There was an error, so record new script and pass on error
                await RecordFormScript(newPath, locale, buildForm, options, initialState, entities, inputs);

                TestContext.AddResultFile(newPath);
                throw;
            }
        }
Exemplo n.º 6
0
        public void SampleFunctionalTest1()
        {
            var webAppUrl  = testContext.Properties["webAppUrl"].ToString();
            var numRetries = 5;

            for (int i = 0; i < numRetries; i++)
            {
                try
                {
                    driver.Navigate().GoToUrl(webAppUrl);
                    Assert.AreEqual("Home Page - My ASP.NET Application", driver.Title, "Expected title to be 'Home Page - My ASP.NET Application'");
                    break;
                }
                catch
                {
                    if (i == (numRetries - 1))
                    {
                        throw;
                    }
                    Thread.Sleep(5000);
                }
            }
            var filePath   = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()) + ".png";
            var screenshot = driver.GetScreenshot();

            screenshot.SaveAsFile(filePath);
            testContext.AddResultFile(filePath);
        }
        public void AfterStepWeb(ScenarioContext scenario, TestContext test)
        {
            string tipoPasso      = ScenarioContext.Current.StepContext.StepInfo.StepInstance.Keyword.ToString();
            string descricaoPasso = ScenarioContext.Current.StepContext.StepInfo.Text;

            test.AddResultFile(ScreenshotHelper.TiraPrint(tipoPasso + descricaoPasso, driver));
        }
Exemplo n.º 8
0
 internal static void WriteResults()
 {
     try
     {
         String content = String.Empty;
         foreach (DataColumn dc in results.Columns)
         {
             content += dc.ColumnName + ",";
         }
         content = content.Remove(content.Length - 1);
         content = content + "\n";
         foreach (DataRow dr in results.Rows)
         {
             foreach (DataColumn dc in results.Columns)
             {
                 content += dr[dc] + ",";
             }
             content = content.Remove(content.Length - 1);
             content = content + "\n";
         }
         //  File.AppendAllText(resultLocation + "\\" + testContext.Properties["__Tfs_TestCaseId__"] + "_Results.csv", content + "\n");
         File.AppendAllText("C:\\result2.csv", content);
         string[] files = Directory.GetFiles(resultLocation);
         foreach (var file in files)
         {
             if (file.Contains(testContext.Properties["__Tfs_TestCaseId__"].ToString()))
             {
                 testContext.AddResultFile(file);
             }
         }
     }
     catch (Exception e)
     {
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Converts all markdown files in the output directory to HTML.
        /// This is easier to read out of the box than the markdown files.
        /// </summary>
        protected void ConvertAllOutputMarkdownFilesToHtml()
        {
            var directory = new DirectoryInfo(GetBuildPackageResultPath(string.Empty, string.Empty));

            if (!directory.Exists)
            {
                return;
            }

            var markdownFiles = directory.GetFiles("*.*", SearchOption.AllDirectories).Where(x => x.Extension == ".md");

            foreach (var markdownFile in markdownFiles)
            {
                try
                {
                    var(contents, extension) = ConvertMarkdownToPdf(File.ReadAllText(markdownFile.FullName));

                    var resultPath = Path.ChangeExtension(markdownFile.FullName, extension);

                    // Convert markdown file to html and replace extension.
                    File.WriteAllBytes(resultPath, contents);
                    TestContext.AddResultFile(resultPath);
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e)
#pragma warning restore CA1031 // Do not catch general exception types
                {
                    _baseTestLogger.LogError(e, $"Failed to convert file to HTML. File {markdownFile}");
                }
            }
        }
Exemplo n.º 10
0
        public void End()
        {
            // Stop counting time
            this.Stopwatch.Stop();

            string filename = TestContext.TestRunDirectory + "/TestsPerformance.txt";
            string text     = "";

            // Write the top of the file
            if (!File.Exists(filename))
            {
                text = "Unit Test run on " + DateTime.Now.ToShortDateString() + " "
                       + DateTime.Now.ToShortTimeString() + Environment.NewLine;
            }

            text += TestContext.TestName + " " + this.Stopwatch.Elapsed.ToString(@"mm\:ss\.fffffff", null);
            text += " ";

            if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
            {
                text += "FAILED";
            }
            else
            {
                text += "SUCCESS";
            }
            text += Environment.NewLine;

            File.AppendAllText(filename, text);


            // Just to keep the test results
            TestContext.AddResultFile("TestsPerformance.txt");
        }
Exemplo n.º 11
0
        public static string SaveEmbeddedResourcesWithPathPrefix(TestContext testContext, Assembly containingAssembly, string manifestFilePrefix)
        {
            var outputDirectory = GetUniqueTestOutputPath(testContext);

            var filesSaved = false;

            foreach (var embeddedResourceName in containingAssembly.GetManifestResourceNames().Where(file => file.StartsWith(manifestFilePrefix, StringComparison.Ordinal)))
            {
                var relativePath   = embeddedResourceName.Substring(manifestFilePrefix.Length).TrimStart('/');
                var manifestStream = containingAssembly.GetManifestResourceStream(embeddedResourceName);
                if (manifestStream == null)
                {
                    throw new ArgumentException($"Failed to load stream for manifest resource {embeddedResourceName}");
                }

                var filePath      = Path.Combine(outputDirectory, relativePath);
                var directoryPath = Path.GetDirectoryName(filePath) ?? throw new AssertFailedException($"There is no directory path for file '{filePath}'.");
                Directory.CreateDirectory(directoryPath);

                var fileStream = File.Create(filePath);
                manifestStream.Seek(0, SeekOrigin.Begin);
                manifestStream.CopyTo(fileStream);
                fileStream.Close();

                testContext.AddResultFile(filePath);
                filesSaved = true;
            }

            if (!filesSaved)
            {
                throw new InvalidOperationException($"Failed to find any manifest files to save in assembly {containingAssembly}");
            }

            return(outputDirectory);
        }
            public TestResults Execute()
            {
                var msTestFullPath = GetMsTestFullPath();

                var trxFile = Path.GetFullPath(Path.GetRandomFileName()) + ".trx";

                var parameters = string.Format("/testContainer:\"{0}\" /resultsFile:\"{1}\"", _fileName, trxFile);
                var startInfo  = new ProcessStartInfo(msTestFullPath, parameters)
                {
                    UseShellExecute        = false,
                    RedirectStandardError  = true,
                    RedirectStandardOutput = true,
                };

                Logger.WriteLine("Executing: {0} {1}", msTestFullPath, parameters);
                using (var msTest = Process.Start(startInfo))
                {
                    msTest.WaitForExit();
                    var output = msTest.StandardOutput.ReadToEnd();
                    var error  = msTest.StandardError.ReadToEnd();
                    Logger.WriteLine("Output:");
                    Logger.WriteLine(output);
                    Logger.WriteLine("Error:");
                    Logger.WriteLine(error);
                }

                Logger.WriteLine("TrxFile: \"file://{0}\"", trxFile);

                _testContext.AddResultFile(trxFile);

                return(new TestResults(trxFile));
            }
        public void CodedUITestMethod1()
        {
            var testPage = Path.Combine(TestContext.DeploymentDirectory, "HTMLPage1.html");
            var window   = BrowserWindow.Launch(testPage);

            // run script before Coded UI interaction to show document.all.item(...) returns a single object
            window.ExecuteScript("foo();");

            window.CaptureImage().Save(Path.Combine(TestContext.DeploymentDirectory, "00-before.png"), ImageFormat.Png);
            TestContext.AddResultFile("00-before.png");

            // Use Coded UI to Find a control but not interact with it
            var radioButton = new HtmlRadioButton(window);

            radioButton.SearchProperties.Add(HtmlControl.PropertyNames.Id, "a");
            radioButton.Find();

            // run script after Coded UI interaction to show document.all.item(...) now returns an array of length 1
            window.ExecuteScript("foo();");

            window.CaptureImage().Save(Path.Combine(TestContext.DeploymentDirectory, "01-after.png"), ImageFormat.Png);
            TestContext.AddResultFile("01-after.png");

            var p = new HtmlCustom(window);

            p.SearchProperties.Add(HtmlControl.PropertyNames.Id, "p");
            StringAssert.DoesNotMatch(p.InnerText, new Regex(@"\.checked : undefined"));
        }
        public void SampleFunctionalTest1()
        {
            var webAppUrl      = testContext.Properties["webAppUrl"].ToString();
            var startTimestamp = DateTime.Now.Millisecond;
            var endTimestamp   = startTimestamp + 60 * 10 * 1000;

            while (true)
            {
                try
                {
                    driver.Navigate().GoToUrl(webAppUrl);
                    Assert.AreEqual("Home Page - My ASP.NET Application", driver.Title, "Expected title to be 'Home Page - My ASP.NET Application'");
                    break;
                }
                catch
                {
                    var currentTimestamp = DateTime.Now.Millisecond;
                    if (currentTimestamp > endTimestamp)
                    {
                        throw;
                    }
                    Thread.Sleep(5000);
                }
            }
            var filePath   = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()) + ".png";
            var screenshot = driver.GetScreenshot();

            screenshot.SaveAsFile(filePath);
            testContext.AddResultFile(filePath);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Add file
 /// </summary>
 /// <param name="callid">The call id</param>
 /// <param name="filepath">The file path</param>
 public void AddFile(string callid, string filepath)
 {
     if (testContext != null)
     {
         testContext.AddResultFile(filepath);
     }
 }
            private void TakeScreenshot(TestContext testContext)
            {
                var filename = Path.GetFullPath(testContext.FullyQualifiedTestClassName + ".jpg");

                try
                {
                    var screenLeft   = SystemInformation.VirtualScreen.Left;
                    var screenTop    = SystemInformation.VirtualScreen.Top;
                    var screenWidth  = SystemInformation.VirtualScreen.Width;
                    var screenHeight = SystemInformation.VirtualScreen.Height;

                    // Create a bitmap of the appropriate size to receive the screenshot.
                    using (var bmp = new Bitmap(screenWidth, screenHeight))
                    {
                        // Draw the screenshot into our bitmap.
                        using (var g = Graphics.FromImage(bmp))
                        {
                            g.CopyFromScreen(screenLeft, screenTop, 0, 0, bmp.Size);
                        }

                        bmp.Save(filename, ImageFormat.Jpeg);
                    }
                    testContext.AddResultFile(filename);
                }
                catch (Exception ex)
                {
                    Logger.WriteLine("An exception occured while trying to take screenshot:");
                    Logger.WriteLine(ex);
                }
            }
        public void CleanUpFront()
        {
            if (TestContext.CurrentTestOutcome != UnitTestOutcome.Passed)
            {
                Test.Fail(GetErrorMessage());
            }

            Extent.Flush();
            Driver.Quit();
            _webDriver.Quit();
            HtmlReporter.Stop();

            using (var sw = new StreamWriter(ExtentFileName, true))
            {
                sw.WriteLine("<style>img {border: 1px solid #ddd;border-radius: 4px;padding: 5px;width: 150px;} img:hover {box-shadow: 0 0 2px 1px rgba(0, 140, 186, 0.5);}</style><script>function OpenImage(src){ var newTab = window.open(); newTab.document.body.innerHTML = " + '"' + "<img src=" + '"' + " + src + " + '"' + ">" + '"' + ";}</script>");
                sw.Close();
            }

            Extent       = null;
            HtmlReporter = null;
            Test         = null;
            Loger        = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
            ExecuteCmd("taskkill /im chromedriver.exe /f /t");
            TestContext.AddResultFile(ExtentFileName);
        }
        private void CreateScreenshot()
        {
            var screenshot = driver.GetScreenshot();

            screenshot.SaveAsFile("startScreen.png", OpenQA.Selenium.ScreenshotImageFormat.Png);
            ctx.AddResultFile("startScreen.png");
        }
Exemplo n.º 19
0
        public void GivenTracesForCrosslineShouldCreateOneImage()
        {
            // Arrange
            var trace1 = new MockTrace {
                Values = new float[] { 99 }, Header = new MockTraceHeader {
                    CrosslineNumber = 1, InlineNumber = 10
                }
            };
            var trace2 = new MockTrace {
                Values = new float[] { 77 }, Header = new MockTraceHeader {
                    CrosslineNumber = 1, InlineNumber = 20
                }
            };
            IEnumerable <ITrace> traces = new ITrace[] { trace1, trace2 };
            var path = TestPath() + ".jpg";

            // Act
            Subject.Write(traces, path);

            // Assert
            BinaryFileAssert.Exists(path);
            TestContext.AddResultFile(path);
            var image = new Bitmap(path);

            Assert.AreEqual(2, image.Width);
            Assert.AreEqual(1, image.Height);
        }
Exemplo n.º 20
0
        public TestResults Execute()
        {
            var msTestFullPath = GetVsTestConsoleFullPath();

            var parameters = $"{_dllName} /UseVsixExtensions:true /logger:trx /TestAdapterPath:.";

            var startInfo = new ProcessStartInfo(msTestFullPath, parameters)
            {
                UseShellExecute        = false,
                RedirectStandardError  = true,
                RedirectStandardOutput = true,
            };

            Logger.WriteLine("Executing: {0} {1}", msTestFullPath, parameters);
            using (var msTest = Process.Start(startInfo))
            {
                msTest.WaitForExit();
                var output = msTest.StandardOutput.ReadToEnd();
                var error  = msTest.StandardError.ReadToEnd();
                Logger.WriteLine("Output:");
                Logger.WriteLine(output);
                Logger.WriteLine("Error:");
                Logger.WriteLine(error);
            }

            const string testResultsFolder = "TestResults";
            var          trxFiles          = new DirectoryInfo(testResultsFolder).EnumerateFiles("*.trx").OrderByDescending(file => file.LastWriteTime);
            var          trxFile           = trxFiles.First().FullName;

            Logger.WriteLine("TrxFile: \"file://{0}\"", trxFile);

            _testContext.AddResultFile(trxFile);

            return(new TestResults(trxFile));
        }
Exemplo n.º 21
0
            private void TakeScreenshot(TestContext testContext)
            {
                var filename = Path.GetFullPath(testContext.FullyQualifiedTestClassName + ".jpg");
                try
                {
                    var screenLeft = SystemInformation.VirtualScreen.Left;
                    var screenTop = SystemInformation.VirtualScreen.Top;
                    var screenWidth = SystemInformation.VirtualScreen.Width;
                    var screenHeight = SystemInformation.VirtualScreen.Height;

                    // Create a bitmap of the appropriate size to receive the screenshot.
                    using (var bmp = new Bitmap(screenWidth, screenHeight))
                    {
                        // Draw the screenshot into our bitmap.
                        using (var g = Graphics.FromImage(bmp))
                        {
                            g.CopyFromScreen(screenLeft, screenTop, 0, 0, bmp.Size);
                        }

                        bmp.Save(filename, ImageFormat.Jpeg);
                    }
                    testContext.AddResultFile(filename);
                }
                catch (Exception ex)
                {
                    Logger.WriteLine("An exception occured while trying to take screenshot:");
                    Logger.WriteLine(ex);
                }
            }
Exemplo n.º 22
0
        public void TestMethod_With_One_Missing_And_One_present_Result_File()
        {
            File.WriteAllText("file.xxx", "file.xxx contents.");
            TestContext.AddResultFile("file.xxx");

            TestContext.AddResultFile("missing.zzz");
            Assert.IsTrue(true);
        }
        public void CleanUpAPI()
        {
            Logger($"Tests: {TestContext.TestName} was {TestContext.CurrentTestOutcome}.");

            Logger($"Tests: {TestContext.TestName} was finished.");

            TestContext.AddResultFile(EvidenceFileName);
        }
Exemplo n.º 24
0
        private static string AssertLogFileExists(string dummyBinDir, string exeName, TestContext testContext)
        {
            string logFilePath = GetLogFilePath(dummyBinDir, exeName);

            Assert.IsTrue(File.Exists(logFilePath), "Expecting the dummy exe log to exist. File: {0}", logFilePath);
            testContext.AddResultFile(logFilePath);
            return(logFilePath);
        }
        public void CreateScreenshot(WindowsDriver <WindowsElement> driver, TestContext ctx)
        {
            var screenshot = driver.GetScreenshot();
            var fileName   = Guid.NewGuid().ToString() + ".png";

            screenshot.SaveAsFile(fileName);
            ctx.AddResultFile(fileName);
        }
 //Funcional
 public HomeLogadaPage Logar(string email, string senha, TestContext test)
 {
     txtEmail.SendKeys(email);
     txtSenha.SendKeys(senha);
     test.AddResultFile(ScreenshotHelper.TiraPrint("Campos Preenchidos", driver));
     btnSignIn.Click();
     return(new HomeLogadaPage(driver));
 }
Exemplo n.º 27
0
        private void CreateScreenshot(WindowsDriver <WindowsElement> driver)
        {
            var screenshot = driver.GetScreenshot();
            var fileName   = Guid.NewGuid().ToString() + ".png";

            screenshot.SaveAsFile(fileName, OpenQA.Selenium.ScreenshotImageFormat.Png);
            ctx.AddResultFile(fileName);
        }
Exemplo n.º 28
0
        public static string TestResultPathFor(TestContext context, string name, string extension = ".txt")
        {
            var path = Path.Combine(context.TestResultsDirectory, context.TestName, Path.ChangeExtension(name, extension));

            context.AddResultFile(path);
            Directory.CreateDirectory(Directory.GetParent(path).FullName);
            return(path);
        }
Exemplo n.º 29
0
        public void CreateScreenshot(AndroidDriver <AppiumWebElement> driver)
        {
            var screenshot = driver.GetScreenshot();
            var fileName   = Guid.NewGuid().ToString() + ".png";

            screenshot.SaveAsFile(fileName);
            _ctx.AddResultFile(fileName);
        }
Exemplo n.º 30
0
        public void AddResultFile(string fileName)
        {
            //TODO: netappcore - add support for files

#if NET461
            context.AddResultFile(fileName);
#endif
        }
Exemplo n.º 31
0
        static public void TakeScreenshot(IWebDriver driver, TestContext ctx)
        {
            var snapshotFile = System.IO.Path.Combine(ctx.ResultsDirectory, sequenceCounter.ToString() + "-" + Guid.NewGuid().ToString() + ".png");;

            ((ITakesScreenshot)driver).GetScreenshot().SaveAsFile(snapshotFile, ScreenshotImageFormat.Png);;
            ctx.AddResultFile(snapshotFile);
            sequenceCounter++;
        }