Ejemplo n.º 1
0
        /// <summary>
        /// This method gets the list of all blogs and returns a list of the hyperlink to the blog and another list of count of blogs per month
        /// </summary>
        /// <param name="blogPom"></param>
        /// <returns>List 1 of blog numbers and list 2 of URLs</returns>
        public (IList <string>, IList <string>) GetBlogItemsText(SwordBlogPom blogPom)
        {
            var           itemsList = blogPom.GetBlogsList();
            int           listCount = itemsList.Count;
            List <string> itemText  = new List <string>(listCount);
            List <string> itemUrl   = new List <string>(listCount);

            for (int i = 0; i < itemsList.Count; i++)
            {
                string newItem = itemsList[i].Text;
                string newUrl  = itemsList[i].FindElement(By.TagName("a")).GetAttribute("href");
                itemText.Add(newItem);
                itemUrl.Add(newUrl);
            }

            return(itemText, itemUrl);
        }
        public void CompareBlogNumbers()
        {
            var blogPom  = new SwordBlogPom(Driver);
            var blogTask = new SwordBlogTask();

            var(blogNumbers, blogUrls) = blogTask.GetBlogItemsText(blogPom);

            for (int i = 0; i < blogNumbers.Count; i++)
            {
                string numberOfBlogs = blogNumbers[i].Split("(")[1];
                int    index         = numberOfBlogs.LastIndexOf(")");
                numberOfBlogs = numberOfBlogs.Substring(0, index);

                Driver.Url = blogUrls[i];
                var blogElement = Driver.FindElements(By.XPath("//*[@class='metaPost']"));
                int count       = blogElement.Count();

                Assert.AreEqual(Convert.ToInt32(numberOfBlogs), count);
            }
        }