//[BeforeScenario("Selenium")] public static void BeforeWebScenarioSelenium(string browserTypeFromConsole, string urlFromConsole, string authUser, string authPass, string authType) { var dictionary = DictionaryInteractions.ReadFromPropertiesFile(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt"); DictionaryInteractions.WriteInTxtFileFromDictionary(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt", dictionary, "tfsReportStatus", ""); var brType = browserTypeFromConsole; var urlToRun = urlFromConsole; switch (brType.ToLower()) { case "ie": Driver.StartBrowser(BrowserTypes.InternetExplorer); Driver.Browser.Manage().Window.Maximize(); UnityContainerFactory.GetContainer().RegisterInstance <IWebDriver>(Driver.Browser); browserType = "IE"; break; case "chrome": Driver.StartBrowser(BrowserTypes.Chrome); Driver.Browser.Manage().Window.Maximize(); UnityContainerFactory.GetContainer().RegisterInstance <IWebDriver>(Driver.Browser); browserType = "Chrome"; break; default: break; } //Driver.Browser.Navigate().GoToUrl(urlToRun); //if(authUser !=null & authPass !=null & authType != null) //{ // Authenticate(authUser, authPass, authType); //} }
//[AfterScenario] public static void AfterScenario(string[] reports) { Driver.StopBrowser(); if (StringOperations.ReturnString.StringIsPartOfArray(reports, "extent")) { extent.Flush(); var status = scenario.Status; if (status == Status.Fail || status == Status.Fatal) { Assert.Fail(); } } else { if (StringOperations.ReturnString.StringIsValueOfArray(reports, "tfs")) { var dictionary = DictionaryInteractions.ReadFromPropertiesFile(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt"); if (dictionary["tfsReportStatus"].ToLower() == "fail") { Assert.Fail(); } } } }
public void ErrorMessageTFS(string errorMessage, string fatalORFailed) { Console.Write(fatalORFailed.ToUpper() + ": " + errorMessage + System.Environment.NewLine + "Screenshot: " + testName + dateFormatFileNameStr + ".png" + System.Environment.NewLine + "StackTrace:" + System.Environment.NewLine + ReturnString.FormatingStackTrace(Environment.StackTrace)); var dictionary = DictionaryInteractions.ReadFromPropertiesFile(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt"); DictionaryInteractions.WriteInTxtFileFromDictionary(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt", dictionary, "tfsReportStatus", "fail"); }
public void SendAck() { _have_sent_ack = 1; byte[] header = new byte[5]; header[0] = (byte)ReqrepType.RequestAck; NumberSerializer.WriteInt(RequestID, header, 1); MemBlock mb_header = MemBlock.Reference(header); ReturnPath.Send(new CopyList(_prefix, mb_header)); }
/** * Resend if we already have the reply, * if we don't have the reply yet, send an Ack */ public void Resend() { try { if (Reply != null) { _rep_date = DateTime.UtcNow; ReturnPath.Send(Reply); } else { SendAck(); } } catch { /* If this doesn't work, oh well */ } }
//[BeforeTestRun] public static void BeforeTestRun(string browserTypeFromConsole, string[] reports) { reportTypes = reports; var brType = browserTypeFromConsole; DateTime thisDay = DateTime.Now; var dictionary = DictionaryInteractions.ReadFromPropertiesFile(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt"); DictionaryInteractions.WriteInTxtFileFromDictionary(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt", dictionary, "Suffix", thisDay.ToString("yyyy.MM.dd HH:mm:ss", CultureInfo.InvariantCulture)); string[] tokens = thisDay.ToString("yyyy.MM.dd HH:mm:ss", CultureInfo.InvariantCulture).Split(':'); string pathString = System.IO.Path.Combine(ReturnPath.ProjectFolderPath() + "../TestResults/" + dictionary["projectName"] + "/", brType + "_TestReport-" + tokens[0] + "h " + tokens[1] + "min " + tokens[2] + "sec"); System.IO.Directory.CreateDirectory(pathString); DictionaryInteractions.WriteInTxtFileFromDictionary(ReturnPath.ProjectFolderPath() + "ExtentReport/ReportProperties.txt", dictionary, "ReportPath", pathString); if (StringOperations.ReturnString.StringIsValueOfArray(reports, "extentX")) { XmlDocument doc = new XmlDocument(); doc.Load(ReturnPath.ProjectFolderPath() + "ExtentReport/ExtentXReportConf.xml"); XmlNode confNode = doc.SelectSingleNode("/configuration"); confNode.FirstChild.FirstChild.Value = dictionary["projectName"] + "-" + tokens[0] + "h " + tokens[1] + "min " + tokens[2] + "sec-" + brType;//FeatureContext.Current.FeatureInfo.Title; doc.Save(ReturnPath.ProjectFolderPath() + "ExtentReport/ExtentXReportConf.xml"); extentX = new ExtentXReporter(); extentX.LoadConfig(ReturnPath.ProjectFolderPath() + "ExtentReport/ExtentXReportConf.xml"); if (StringOperations.ReturnString.StringIsValueOfArray(reports, "extent")) { extentHTML = new ExtentHtmlReporter(pathString + "/TestReport-" + tokens[0] + "h " + tokens[1] + "min " + tokens[2] + "sec-" + brType + ".html"); extent = new ExtentReports(); extent.AttachReporter(extentHTML, extentX); } else { extent.AttachReporter(extentX); } } else { if (StringOperations.ReturnString.StringIsValueOfArray(reports, "extent")) { extentHTML = new ExtentHtmlReporter(pathString + "/TestReport-" + tokens[0] + "h " + tokens[1] + "min " + tokens[2] + "sec-" + brType + ".html"); extent = new ExtentReports(); extent.AttachReporter(extentHTML); } } }
public void CreateUpdateTC() { var allFiles = Directory.GetFiles(ReturnPath.ProjectFolderPath() + "Features"); Assembly a = typeof(BaseStepDefinitionsReInitialization).Assembly; var ab = a.GetTypes(); foreach (string an in allFiles) { Debug.WriteLine("FileName: " + an); if (an.Contains(".feature") && an.Contains(".cs")) { //var filePath = System.IO.File.ReadAllText(an); //var scenarios = filePath.Split(new string[] { "[NUnit.Framework.TestAttribute()]" }, StringSplitOptions.None); //var featureName = scenarios[0].Split(new string[] { "[NUnit.Framework.TestFixtureAttribute()]" }, StringSplitOptions.None)[1].Split(new string[] { "[NUnit.Framework.DescriptionAttribute(\"" }, StringSplitOptions.None)[1].Split(new string[] { "\")" }, StringSplitOptions.None)[0].Trim(); KPMG.TestAutomation.Reports.TFS.Helper.TFSConnection(an); } } }
/// <summary> /// Goes from this Tile in specified direction, measuring outgoing rail /// </summary> public ReturnPath getRailOutTo(Direction d) { ReturnPath p = new ReturnPath(); if (neighbors.ContainsKey(d) && neighbors[d] != null) { ReturnPath r = neighbors[d].getRailOutFrom(Utilities.oppositeDirection(d)); p.EndsWithStation = r.EndsWithStation; p.PathLength = r.PathLength + 1; p.stationColor = r.stationColor; p.stationNumber = r.stationNumber; return(p); } else { //Ends with station? int ews = EndsWithStation(d); if (ews == -1) { //No station p.EndsWithStation = false; p.PathLength = 1; } else if (ews == 0) { //Middle station p.EndsWithStation = true; p.PathLength = 1; p.stationColor = PlayerColor.None; p.stationNumber = 0; } else { //Normal station p.EndsWithStation = true; p.PathLength = 1; p.stationColor = parent.GetStationColor(ews); p.stationNumber = ews; } } return(p); }
private string DoTheConvert(string sourceImage, string actionProfile, string annotate, ReturnPath retPath) { string strRetFile = ""; strActionProfile = actionProfile; strAnnotate = annotate; this.sourceImage = sourceImage; try { RasterCodecs.Startup(); RasterSupport.Unlock(RasterSupportType.Pro, "LhwcFdF3jN"); bool isLocked = RasterSupport.IsLocked(RasterSupportType.Pro); rasterCodecs = new RasterCodecs(); imageInfo = rasterCodecs.GetInformation(sourceImage, true); if (imageInfo.TotalPages > 0 && imageInfo.Format == Leadtools.RasterImageFormat.Gif) { rasterCodecs.Options.Gif.Load.AnimationLoop = imageInfo.Gif.AnimationLoop; rasterCodecs.Options.Gif.Save.AnimationLoop = imageInfo.Gif.AnimationLoop; rasterCodecs.Options.Gif.Save.UseAnimationLoop = imageInfo.Gif.HasAnimationLoop; if (imageInfo.Gif.HasAnimationBackground) { rasterCodecs.Options.Gif.Save.AnimationBackground = imageInfo.Gif.AnimationBackground; } rasterCodecs.Options.Gif.Save.UseAnimationBackground = imageInfo.Gif.HasAnimationBackground; // #1.0.5.0 if (imageInfo.Gif.HasAnimationPalette) { rasterCodecs.Options.Gif.Save.SetAnimationPalette(imageInfo.Gif.GetAnimationPalette()); } rasterCodecs.Options.Gif.Save.UseAnimationPalette = imageInfo.Gif.HasAnimationPalette; rasterCodecs.Options.Gif.Save.AnimationWidth = imageInfo.Gif.AnimationWidth; rasterCodecs.Options.Gif.Save.AnimationHeight = imageInfo.Gif.AnimationHeight; } img = rasterCodecs.Load(sourceImage); // Load convert action profile if (Init(sourceImage, strActionProfile)) { // loop on actions LoopActions(); SaveImage(); // add a copyright or something like this to the image if (xmlActionProfile.SelectSingleNode("//root/actionProfile[@ID='" + strActionProfile + "']/action[@ID='annotate']") != null && strTargetImage.Length > 0) { Annotate(); } if (retPath == ReturnPath.AbsPath) { strRetFile = strTargetImage; } else if (retPath == ReturnPath.Url) { strRetFile = strTargetImageUrl; } } } finally { img.Dispose(); RasterCodecs.Shutdown(); } return(strRetFile); }
public string DoConvert(string sourceImage, string actionProfile, string annotate, ReturnPath retPath) { return(DoTheConvert(sourceImage, actionProfile, annotate, retPath)); }
public static void AddScreenshots(string tfsURL, string tfsToken, string projectId, string buildDefinitionName, string projectName, string nameOfProjectWithTests) { var dictionary = DictionaryInteractions.ReadFromPropertiesFile(ReturnPath.SolutionFolderPath() + nameOfProjectWithTests + "/ExtentReport/ReportProperties.txt"); string[] fileArray = Directory.GetFiles(dictionary["ReportPath"]); var onlyScreenshots = fileArray.Where(s => s.IndexOf(".png") != -1); if (onlyScreenshots.ToList().Count != 0) { VssConnection vc = new VssConnection(new Uri(tfsURL), new VssBasicCredential(string.Empty, tfsToken)); BuildHttpClient bhc = vc.GetClient <BuildHttpClient>(); ProjectHttpClient ddd = vc.GetClient <ProjectHttpClient>(); //ITestManagementTeamProject ddd1 = ddd.GetProject("hgfyjh"); var buildsPerProject = bhc.GetBuildsAsync(projectId).GetAwaiter().GetResult(); var lastBuildId = buildsPerProject.Where <Build>(x => x.Definition.Name == buildDefinitionName).Max <Build>(z => z.Id); Build lastBuild = buildsPerProject.FirstOrDefault <Build>(x => x.Id == lastBuildId); Console.Write("Last Build Number: " + lastBuildId); TestManagementHttpClient ithc = vc.GetClient <TestManagementHttpClient>(); QueryModel qm = new QueryModel("Select * From TestRun Where BuildNumber Contains '" + lastBuild.BuildNumber + "'"); List <TestRun> testruns = ithc.GetTestRunsByQueryAsync(qm, projectName).Result; Console.Write("testruns.Count: " + testruns.Count); foreach (TestRun testrun in testruns) { List <TestCaseResult> testresults = ithc.GetTestResultsAsync(projectName, testrun.Id).Result; Console.Write("testresults.Count: " + testresults.Count); foreach (TestCaseResult tcr in testresults) { var testNamesFromScreents = onlyScreenshots.Select(s => s.ToLower().Split(new string[] { "sec\\" }, StringSplitOptions.None)[1].Split(new string[] { "20" }, StringSplitOptions.None)[0]).Distinct(); //var screentsShotPerTest = onlyScreenshots.Where(s => s.Split(new string[] { "sec\\" }, StringSplitOptions.None)[1].Split(new string[] { "20" }, StringSplitOptions.None)[0] == scenarioName.Replace(" ", string.Empty)); Console.WriteLine("tcr.Id: " + tcr.Id); if (testNamesFromScreents.ToList().Contains(tcr.AutomatedTestName.Split('.').Last().ToLower())) { Console.WriteLine("recognize Test: " + tcr.AutomatedTestName.Split('.').Last().ToLower()); using (var client = new HttpClient()) { string credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", tfsToken))); client.BaseAddress = new Uri(tfsURL); //url of our account client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials); var screentsShotPerTest = onlyScreenshots.Where(s => s.Split(new string[] { "sec\\" }, StringSplitOptions.None)[1].Split(new string[] { "20" }, StringSplitOptions.None)[0].ToLower() == tcr.AutomatedTestName.Split('.').Last().ToLower()); foreach (var screenshot in screentsShotPerTest) { Console.WriteLine("screentsShotPerTest: " + screenshot); var post = new PostImageTfs() { Stream = Convert.ToBase64String(File.ReadAllBytes(screenshot)), AttachmentType = "GeneralAttachment", Comment = "screenshot of error", FileName = screenshot.Split(new string[] { "sec\\" }, StringSplitOptions.None)[1] }; Console.WriteLine("tcr.TestRun.Id: " + tcr.TestRun.Id); Console.WriteLine("tcr.Id: " + tcr.Id); Console.WriteLine("screenshot.Split(new string[] { DateTime.Now.Year.ToString() }, StringSplitOptions.None)[2] " + screenshot.Split(new string[] { DateTime.Now.Year.ToString() }, StringSplitOptions.None)[2]); var test = new StringContent($"{{\"stream\": \"{post.Stream}\",\"fileName\": \"{post.FileName}\",\"comment\": \"{post.Comment}\",\"attachmentType\": \"{post.AttachmentType}\"}}", Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync("/DefaultCollection/" + projectName + "/_apis/test/runs/" + tcr.TestRun.Id + "/results/" + tcr.Id + "/attachments?api-version=2.0-preview.1", test).Result; Console.WriteLine("response: " + response.StatusCode); } } } } } } }