public NavigationBlock(IWebDriver driver) : base(driver) { nextSlideButton = UlearnDriver.FindElementSafely(Driver, ElementsId.NextNavArrow); prevSlideButton = UlearnDriver.FindElementSafely(Driver, ElementsId.PrevNavArrow); nextSolutionsButton = UlearnDriver.FindElementSafely(Driver, ElementsId.NextSolutionsButton); CheckButtons(); }
public void TestUnits() { using (var driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); UlearnDriver ulearnDriver = new UlearnDriver(driver); var regPage = ulearnDriver.GoToRegistrationPage(); var random = new Random(); var login = random.Next().ToString(); var password = random.Next().ToString(); regPage.SignUp(login, password); var startPage = ulearnDriver.GoToStartPage(); startPage.GoToCourse(Titles.BasicProgrammingTitle); var toc = ulearnDriver.GetToc(); var unitsNames = toc.GetUnitsName(); foreach (var unitName in unitsNames) { if (!ulearnDriver.GetToc().GetUnitControl(unitName).Collapse) { ulearnDriver.GetToc().GetUnitControl(unitName).Click(); } var slidesNames = ulearnDriver.GetToc().GetUnitControl(unitName).GetSlidesName(); foreach (var slideName in slidesNames) { ulearnDriver.GetToc().GetUnitControl(unitName).GetSlides().First(x => x.Name == slideName).Click(); } } } }
public void TestUnits() { using (var driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); UlearnDriver ulearnDriver = new UlearnDriver(driver); var regPage = ulearnDriver.GoToRegistrationPage(); var random = new Random(); var login = random.Next().ToString(); var password = random.Next().ToString(); regPage.SignUp(login, password); var startPage = ulearnDriver.GoToStartPage(); startPage.GoToCourse(Titles.BasicProgrammingTitle); var toc = ulearnDriver.GetToc(); var unitsNames = toc.GetUnitsName(); foreach (var unitName in unitsNames) { if (!ulearnDriver.GetToc().GetUnitControl(unitName).Collapse) ulearnDriver.GetToc().GetUnitControl(unitName).Click(); var slidesNames = ulearnDriver.GetToc().GetUnitControl(unitName).GetSlidesName(); foreach (var slideName in slidesNames) { ulearnDriver.GetToc().GetUnitControl(unitName).GetSlides().First(x => x.Name == slideName).Click(); } } } }
public ChoiseBlock(List <QuizItem> quizItems, bool isMultiply, IWebElement statusElement, QuizStatus quizStatus) { this.quizItems = quizItems; this.isMultiply = isMultiply; blockStatus = quizItems.Any(x => x.GetStatus() == Status.Wrong) ? Status.Wrong : quizItems.Any(x => x.GetStatus() == Status.Right) ? Status.Right : Status.Undefined; var localStatus = UlearnDriver.HasCss(statusElement, "glyphicon-ok") ? Status.Right : UlearnDriver.HasCss(statusElement, "glyphicon-remove") ? Status.Wrong : Status.Undefined; if (localStatus != blockStatus) { throw new Exception("Не верно произведена оценка квиза"); } if (quizStatus == QuizStatus.NoAttempts && localStatus == Status.Undefined) { throw new Exception("Не произведена проверка квиза"); } if (quizStatus == QuizStatus.HasAttempts && quizItems.Any(x => x.GetStatus() == Status.Wrong || x.GetStatus() == Status.Right)) { throw new Exception("Отмечены верные/неверные варианты ответа при имеющихся попытках"); } if (quizStatus == QuizStatus.Clean && (quizItems.Any(x => x.GetStatus() == Status.Wrong || x.GetStatus() == Status.Right)) || (localStatus != Status.Undefined)) { throw new Exception("Отмечены верные/неверные варианты ответа или выставлены оценки квиз-блокам, когда квиз еще не решался"); } }
public SlideLabelInfo GetInfo() { if (slideLabelElement == null) { return(new SlideLabelInfo(false, false)); } var element = slideLabelElement.Value; var isVisited = IsVisited(element); var selected = IsSelected(slideElement.Value); if (UlearnDriver.HasCss(element, "glyphicon-edit")) { return(new ExerciseSlideLabelInfo(isVisited, selected, IsPassed(element))); } if (UlearnDriver.HasCss(element, "glyphicon-ok")) { return(new SlideLabelInfo(isVisited, selected)); } if (UlearnDriver.HasCss(element, "glyphicon-pushpin")) { var isPassed = IsPassed(element); var isHasAttempts = IsHasAttempts(element); return(new QuizSlideLabelInfo(isVisited, selected, isPassed, isHasAttempts)); } return(new SlideLabelInfo(false, false)); //throw new NotFoundException("navbar-label is not found"); }
private void Configure() { var unitsElements = UlearnDriver.FindElementsSafely(driver, By.XPath(XPaths.TocUnitsXPath)).ToList(); CreateCollections(); for (var i = 0; i < unitsElements.Count; i++) { var unitName = unitsElements[i].Text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); if (unitName == null) { throw new Exception(string.Format("Юнит с номером {0} в курсе {1} не имеет названия", i, driver.Title)); } if (unitName == "Total statistics" || unitName == "Users statistics" || unitName == "Personal statistics") { if (!statistics.ContainsKey(unitName)) { statistics.Add(unitName, new TocUnit(driver, i)); } } else { if (units.ContainsKey(unitName)) { continue; } var collapsedElement = UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.UnitInfoXPath(i))); var isCollapsed = UlearnDriver.HasCss(collapsedElement, "collapse in"); initInfo.Add(unitName, new UnitInitInfo(unitsElements[i], i, isCollapsed)); units.Add(unitName, new Lazy <ITocUnit>(() => new TocUnit(driver, initInfo[unitName].Index))); } } }
private void Configure() { loginField = UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.RegistrationNameField)); passwordField = UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.RegistrationPasswordField)); confirmPasswordField = UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.RegistrationConfirmPasswordField)); registerButton = UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.RegistrationRegisterButton)); CheckPage(); }
public QuizItem(IWebElement box, IWebElement textElement, IWebElement infoElement) { this.box = box; this.textElement = textElement; this.infoElement = infoElement; itemStatus = UlearnDriver.HasCss(infoElement, "wrong-quiz") ? Status.Wrong : UlearnDriver.HasCss(infoElement, "right-quiz") ? Status.Right : Status.Undefined; }
private new void Configure() { base.Configure(); submitButton = UlearnDriver.FindElementSafely(driver, ElementsClasses.QuizSubmitButton); submitAgainButton = UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.QuizSubmitAgainButtonXPath)); submitAgainStatus = UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.QuizSubmitAgainStatusXPath)); quizStatus = GetQuizStatus(); }
public LikeButton(IWebElement like) { if (like == null) { throw new NotFoundException("like button not found"); } this.like = like; isLiked = UlearnDriver.HasCss(like, "btn-primary"); }
private bool IsHasAttempts(IWebElement webElement) { if (webElement == null) { return(false); } return(UlearnDriver.FindElementSafely(driver, By.Id("quiz-submit-btn")) != null || UlearnDriver.FindElementSafely(driver, By.Id("SubmitQuiz")) != null); }
public void GetStartPage() { using (var driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); var ulearnDriver = new UlearnDriver(driver); var startPage = ulearnDriver.Get <StartPage>(); Assert.AreEqual(PageType.StartPage, ulearnDriver.GetCurrentPageType()); } }
public SlideListItem(IWebDriver driver, int slideIndex, int unitIndex) { this.slideIndex = slideIndex; this.unitIndex = unitIndex; this.driver = driver; slideElement = new Lazy <IWebElement>( () => UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.TocSlideXPath(unitIndex, slideIndex)))); slideLabelElement = new Lazy <IWebElement>( () => UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.TocSlideLabelXPath(unitIndex, slideIndex)))); }
public void RunSolution() { using (var driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); UlearnDriver ulearnDriver = new UlearnDriver(driver); ulearnDriver.LoginAdminAndGoToCourse(Titles.BasicProgrammingTitle); driver.Navigate().GoToUrl("https://localhost:44300/Course/BasicProgramming/Slide/21"); } }
public void GetStartPage() { using (var driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); var ulearnDriver = new UlearnDriver(driver); var startPage = ulearnDriver.Get<StartPage>(); Assert.AreEqual(PageType.StartPage, ulearnDriver.GetCurrentPageType()); } }
private List <SlidePageBlock> GetBlocks() { var blockElements = UlearnDriver.FindElementsSafely(driver, By.XPath(XPaths.SeleniumTextBlockXPath)); return(UnionSubBlocks(blockElements.Where( x => x.TagName == "textarea" || x.TagName == "p" || x.TagName == "ul" || (x.TagName == "div" && UlearnDriver.HasCss(x, "video-container"))) .Select(CreateBlock))); }
private void Configure() { headerElement = UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.TocUnitHeaderXPath(unitIndex))); var slidesCount = UlearnDriver.FindElementsSafely(driver, By.XPath(XPaths.TocSlidesXPath(unitIndex))).Count; //UlearnDriver.courseManager.GetCourse(courseTitle).Slides.Count(x => x.Info.UnitName == unitName); slides = new List <Lazy <ITocSlide> >(slidesCount); for (var ind = 0; ind < slidesCount; ind++) { var lazyIndex = ind; slides.Add(new Lazy <ITocSlide>(() => new TocSlideControl(driver, lazyIndex, unitIndex))); } }
public void LoginVk() { using (var driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); var ulearnDriver = new UlearnDriver(driver); var startPage = ulearnDriver.Get <StartPage>(); var signInPage = startPage.GoToSignInPage(); signInPage.LoginVk(); Assert.AreEqual(Admin.Login, ulearnDriver.GetCurrentUserName()); } }
public void LoginVk() { using (var driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); var ulearnDriver = new UlearnDriver(driver); var startPage = ulearnDriver.Get<StartPage>(); var signInPage = startPage.GoToSignInPage(); signInPage.LoginVk(); Assert.AreEqual(Admin.Login, ulearnDriver.GetCurrentUserName()); } }
public void CheckAnswers() { using (var driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); UlearnDriver ulearnDriver = new UlearnDriver(driver); ulearnDriver.GoToRegistrationPage(); var registrationPage = ulearnDriver.Get<RegistrationPage>(); ulearnDriver.LoginAdminAndGoToCourse(Titles.BasicProgrammingTitle); //var first var page = ulearnDriver.Get<SlidePage>(); } }
public void CheckAnswers() { using (var driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); UlearnDriver ulearnDriver = new UlearnDriver(driver); ulearnDriver.GoToRegistrationPage(); var registrationPage = ulearnDriver.Get <RegistrationPage>(); ulearnDriver.LoginAdminAndGoToCourse(Titles.BasicProgrammingTitle); //var first var page = ulearnDriver.Get <SlidePage>(); } }
private static IEnumerable<string> FindTexErrors(string courseId) { using (var driver = new UlearnDriver()) { driver.GoToRegistrationPage().SignUpAsRandomUser(); return ( from page in driver.EnumeratePages(courseId) from tex in driver.TeX where !tex.IsRendered select page.GetSlideName() + " TeX is not rendered! " + tex.GetContent() ).ToList(); } }
private static IEnumerable <string> FindTexErrors(string courseId) { using (var driver = new UlearnDriver()) { driver.GoToRegistrationPage().SignUpAsRandomUser(); return(( from page in driver.EnumeratePages(courseId) from tex in driver.TeX where !tex.IsRendered select page.GetSlideName() + " TeX is not rendered! " + tex.GetContent() ).ToList()); } }
public void NotBeLoggedIn() { using (var driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); UlearnDriver ulearnDriver = new UlearnDriver(driver); var startPage = ulearnDriver.Get <StartPage>(); startPage.GoToSignInPage(); ulearnDriver.GoToStartPage(); var isLogin = ulearnDriver.LoggedIn; Assert.IsFalse(isLogin); } }
private QuizBlock GetBlock(IWebElement webElement, int index) { if (UlearnDriver.HasCss(webElement, "quiz-block-input")) { return(new FillInBlock(webElement.FindElement(By.XPath(XPaths.QuizFillInBlockField(index))))); } return(new ChoiseBlock( webElement .FindElements(By.XPath(XPaths.QuizItemXPath(index))) .Select((x, i) => new QuizItem(x, x, webElement.FindElement(By.XPath(XPaths.QuizItemInfoXPath(i))))) .ToList(), UlearnDriver.HasCss(webElement, "checkbox"), driver.FindElement(By.XPath(XPaths.QuizQuestionStatusXPath(index))), quizStatus)); }
private List <Hint> GetHints() { const string hintXpath = "hyml/body/div[1]/div/div/div/div[9]/div/div"; var allHints = UlearnDriver.FindElementsSafely(driver, By.XPath(hintXpath)); // driver.FindElement(By.Id("hint-place")).FindElements(); var localHints = new List <Hint>(allHints.Count); for (var i = 0; i < allHints.Count; i++) { var likeButton = allHints[i].FindElement(By.Id(String.Format("{0}likeHint", i))); var hint = allHints[i].FindElement(By.XPath(hintXpath + "/p")); localHints[i] = new Hint(new LikeButton(likeButton), hint); } return(localHints); }
public void NotBeLoggedIn() { using (var driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); UlearnDriver ulearnDriver = new UlearnDriver(driver); var startPage = ulearnDriver.Get<StartPage>(); startPage.GoToSignInPage(); ulearnDriver.GoToStartPage(); var isLogin = ulearnDriver.LoggedIn; Assert.IsFalse(isLogin); } }
private new void Configure() { base.Configure(); var modal = UlearnDriver.FindElementSafely(driver, By.Id("selectGroupModal")); if (modal == null) { return; } Console.WriteLine("Close modal"); IsUserFirstVisit = false; //пока сами закрываем окошко выбора группы groupSelector = UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.UserGroupSelectField)); groupSelectButton = UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.UserGroupSelectButton)); groupSelector.SendKeys("0"); groupSelectButton.Click(); }
private static SlidePageBlock CreateBlock(IWebElement element) { if (element.TagName == "p") { return(new SlidePageTextBlock(element.Text)); } if (UlearnDriver.HasCss(element, "video-container")) { return(new SlidePageVideoBlock()); } if (UlearnDriver.HasCss(element, "code-sample")) { return(new SlidePageCodeBlock(element.Text, false)); } return(new SlidePageCodeBlock(element.Text, true)); }
public void GoToSignInPage() { using (IWebDriver driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); UlearnDriver ulearnDriver = new UlearnDriver(driver); var startPage = ulearnDriver.Get <StartPage>(); startPage.GoToSignInPage(); Assert.AreEqual(PageType.SignInPage, ulearnDriver.GetCurrentPageType()); ulearnDriver.GoToStartPage(); var isLogin = ulearnDriver.LoggedIn; Assert.IsFalse(isLogin); } }
public UlearnPage(IWebDriver driver) { this.driver = driver; var mayBeExceptionH1 = driver.FindElements(By.XPath("html/body/span/h1")).FirstOrDefault(); var mayBeExceptionH2 = driver.FindElements(By.XPath("html/body/span/h2")).FirstOrDefault(); if (mayBeExceptionH1 == null) { return; } var pathToScreenshot = UlearnDriver.SaveScreenshot(driver); throw new Exception(mayBeExceptionH1.Text + "\r\n" + mayBeExceptionH2.Text + "\r\n" + "Sreenshot:\r\n" + pathToScreenshot); }
public void GoToSignInPage() { using (IWebDriver driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); UlearnDriver ulearnDriver = new UlearnDriver(driver); var startPage = ulearnDriver.Get<StartPage>(); startPage.GoToSignInPage(); Assert.AreEqual(PageType.SignInPage, ulearnDriver.GetCurrentPageType()); ulearnDriver.GoToStartPage(); var isLogin = ulearnDriver.LoggedIn; Assert.IsFalse(isLogin); } }
public void EnumeratePages() { var exceptions = new List<Exception>(); var screenshotsPath = new List<string>(); var r = new Random(); var login = r.Next().ToString(); var password = r.Next().ToString(); using (var driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); var uDriver = new UlearnDriver(driver); var regPage = uDriver.GoToRegistrationPage(); regPage.SignUp(login, password); var pages = uDriver.EnumeratePages("ForTests", login, password); TestAllSlides(pages, uDriver, exceptions, screenshotsPath, driver); } Verdict(exceptions, screenshotsPath); }
private static void TestAllSlides(IEnumerable <SlidePage> pages, UlearnDriver uDriver, List <Exception> exceptions, List <string> screenshotsPath, IWebDriver driver) { foreach (var test in pages .Select((x, i) => new { Value = x, Index = i })) { try { Console.WriteLine("Page #" + test.Index); TestFactory[test.Index](uDriver, test.Value); } catch (Exception e) { Console.WriteLine(e.Message); exceptions.Add(e); screenshotsPath.Add(UlearnDriver.SaveScreenshot(driver)); } } }
public void EnumeratePages() { var exceptions = new List <Exception>(); var screenshotsPath = new List <string>(); var r = new Random(); var login = r.Next().ToString(); var password = r.Next().ToString(); using (var driver = new ChromeDriver()) { driver.Navigate().GoToUrl(ULearnUrls.StartPage); var uDriver = new UlearnDriver(driver); var regPage = uDriver.GoToRegistrationPage(); regPage.SignUp(login, password); var pages = uDriver.EnumeratePages("ForTests", login, password); TestAllSlides(pages, uDriver, exceptions, screenshotsPath, driver); } Verdict(exceptions, screenshotsPath); }
private static void TestGoodTex(UlearnDriver driver, SlidePage page) { Assert.IsTrue(driver.TeX.All(x => x.IsRendered)); }
private static void TestAllSlides(IEnumerable<SlidePage> pages, UlearnDriver uDriver, List<Exception> exceptions, List<string> screenshotsPath, IWebDriver driver) { foreach (var test in pages .Select((x, i) => new {Value = x, Index = i})) { try { Console.WriteLine("Page #" + test.Index); TestFactory[test.Index](uDriver, test.Value); } catch (Exception e) { Console.WriteLine(e.Message); exceptions.Add(e); screenshotsPath.Add(UlearnDriver.SaveScreenshot(driver)); } } }
public string GetSlideName() { var element = UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.SlideHeaderXPath)); return(element == null ? null : element.Text); }
private static void TestQuizSlidePage(UlearnDriver driver, SlidePage page) { return; }
private void Configure() { name = new Lazy <string>( () => UlearnDriver.FindElementSafely(driver, By.XPath(XPaths.TocSlideXPath(unitIndex, slideIndex))).Text); item = new Lazy <SlideListItem>(() => new SlideListItem(driver, slideIndex, unitIndex)); }
private static bool IsPassed(IWebElement webElement) { return(UlearnDriver.HasCss(webElement, "navbar-label-success")); }
private static void TestExerciseSlidePage(UlearnDriver driver, SlidePage page) { return; }
private static void TestVideoBlock(UlearnDriver driver, SlidePage page) { Assert.IsTrue(page.Blocks.First() is SlidePageVideoBlock); Assert.AreEqual(1, page.Blocks.Count); }
private static void TestTextBlocks(UlearnDriver driver, SlidePage page) { Assert.AreEqual(1, page.Blocks.Count); Assert.AreEqual("Параграф 1\r\nПараграф 2\r\nПараграф 3", ((SlidePageTextBlock)page.Blocks.First()).Text); }