Exemple #1
0
 // TODO: Create assert statement
 /// <summary>
 /// Click the location links on the left side of the page
 /// </summary>
 public void ClickLocationsLinks()
 {
     LocationsTab.WaitAndClick(_driver);
     for (int i = 0; i < LocationLinks.Count; i++)
     {
         Console.WriteLine("Page: Clicking {0}", LocationLinks[i].Text);
         LocationLinks[i].WaitAndClick(_driver);
     }
 }
Exemple #2
0
        /// <summary>
        /// Check all links to make sure they are valid.
        /// </summary>
        public void CheckForBrokenLinks()
        {
            //var helper = new LinkHelpers();
            int broken = 0; // counts broken links
            IList <IWebElement> links = AllLinks;

            // add the location links to the list
            LocationsTab.WaitAndClick(_driver);
            for (int i = 0; i < LocationLinks.Count; i++)
            {
                links.Add(LocationLinks[i]);
            }

            foreach (IWebElement link in links)
            {
                try
                {
                    string url = link.GetAttribute("href");

                    // Make sure to check only valid URLs
                    if (!url.Contains("javascript:"))
                    {
                        HttpStatusCode linkStatusCode = LinkHelpers.GetLinkStatusCode(url);
                        if (linkStatusCode == HttpStatusCode.OK)
                        {
                            Console.WriteLine("{0} is valid", url);
                        }
                        else
                        {
                            Console.WriteLine("{0} is broken, returns a status code of {1}", url, linkStatusCode);
                            broken++;
                        }
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            Console.Out.WriteLine("There are {0} broken links", broken);
        }
Exemple #3
0
 /// <summary>
 /// Click the Locations tab
 /// </summary>
 public void ClickLocationsTab()
 {
     LocationsTab.WaitAndClick(_driver);
 }