public void CheckMark(string mark) { Actions action = new Actions(Driver.Instance); if (mark + ".0000" != GetMark(theme)) { throw new System.Exception("The mark is not correct. Expected: " + mark + ".0000, Got: " + GetMark(theme)); } ReviewPage.ViewModeActivate(theme); var finalReviewButton = Driver.Instance.FindElement(By.XPath("//div[contains(text(), 'Коментари')]")); action.MoveToElement(finalReviewButton).Click().Release().Perform(); //finalReviewButton.Click(); var commentFieldText = Driver.Instance.FindElement(By.XPath("/html/body/div[4]/div[1]/div")).Text; //string firstline = str.Substring(0, str.IndexOf(Environment.NewLine)); commentFieldText = commentFieldText.Substring(0, commentFieldText.IndexOf(Environment.NewLine)); if (commentFieldText != mark + " от 10 точки") { ReviewPage.ReviewModeExit(); throw new System.Exception("The mark is not correct. Expected: " + mark + " от 10 точки, Got: " + commentFieldText); } ReviewPage.ReviewModeExit(); }
public void Check() { ReviewPage.ViewModeActivate(theme); var elements = Driver.Instance.FindElements(By.TagName(type)); for (int i = 0; i < elements.Count(); i++) { if (elements[i].Text == this.text) { Actions action = new Actions(Driver.Instance); action.MoveToElement(elements[i]).Click().Build().Perform(); var commentFieldText = Driver.Instance.FindElement(By.XPath("/html/body/div[5]/div[2]/div")).Text; if (commentFieldText != this.review) { ReviewPage.ReviewModeExit(); throw new System.Exception("The review is not correct or not saved. Expected: " + this.review + ", Got: " + commentFieldText); } ReviewPage.ReviewModeExit(); return; } } ReviewPage.ReviewModeExit(); throw new System.Exception("The element, containing the comment, cannot be found"); }
public void MakeScreenshot(string actual, string expected, string result, string workingDir, string refPath) { ReviewPage.ViewModeActivate(theme); actual = workingDir + "\\" + actual; expected = workingDir + "\\" + expected; result = workingDir + "\\" + result; refPath = workingDir + "\\" + refPath; Screenshot screenshot = ((ITakesScreenshot)Driver.Instance).GetScreenshot(); screenshot.SaveAsFile(@actual, ScreenshotImageFormat.Png); Driver.Instance.Navigate().GoToUrl("file:///" + refPath); screenshot = ((ITakesScreenshot)Driver.Instance).GetScreenshot(); screenshot.SaveAsFile(@expected, ScreenshotImageFormat.Png); Process process = new Process(); process.StartInfo.FileName = "cmd.exe"; process.StartInfo.WorkingDirectory = @workingDir; process.StartInfo.Arguments = "/c magick compare " + actual + " " + expected + " " + result; process.Start(); }
public void CheckFinal() { Actions action = new Actions(Driver.Instance); ReviewPage.ViewModeActivate(theme); var finalReviewButton = Driver.Instance.FindElement(By.XPath("//div[contains(text(), 'Коментари')]")); action.MoveToElement(finalReviewButton).Click().Release().Perform(); //finalReviewButton.Click(); var commentFieldText = Driver.Instance.FindElement(By.ClassName("__ht__blockquote")).Text; //string firstline = str.Substring(0, str.IndexOf(Environment.NewLine)); commentFieldText = commentFieldText.Substring(commentFieldText.IndexOf(Environment.NewLine) + 2); if (commentFieldText != this.review) { ReviewPage.ReviewModeExit(); throw new System.Exception("The review is not correct or not saved. Expected: " + this.review + ", Got: " + commentFieldText); } ReviewPage.ReviewModeExit(); }