Example #1
0
        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)));
                }
            }
        }
Example #2
0
        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)));
        }
Example #3
0
        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)));
            }
        }
        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);
        }