/// <summary>
 /// Check to see if the resume is displayed on the Quick Look page
 /// </summary>
 /// <returns>True if an image is displayed, false otherwise</returns>
 public bool IsResumeDisplayed()
 {
     try
     {
         var imageUri = _driver.FindElement(By.CssSelector("#DocumentDiv img")).GetAttribute("src");
         return(LinkHelpers.GetLinkStatusCode(imageUri) == HttpStatusCode.OK);
     }
     catch (NoSuchElementException)
     {
         return(false);
     }
 }
Пример #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);
        }
        public void Health_Check_OK()
        {
            var environmentUrl = new Uri(ConfigurationManager.AppSettings["BaseUrl.ApplitrackLoginPage"]);
            var environment    = environmentUrl.Host.Split('.').First();

            // Assume that the URL from the config uses a subdomain or uses www, if not this will probably break
            var healthCheckUrl = "https://" + environment + ".applitrack.com/healthcheck.aspx";

            try  //Contains Contents of Test
            {
                var healthStatus = LinkHelpers.GetLinkStatusCode(healthCheckUrl);

                Assert.IsTrue(healthStatus == HttpStatusCode.OK,
                              "Health check returned: {0}", healthStatus);

                test.Log(LogStatus.Pass, "Health check (" + healthCheckUrl + ") returned HTTP status of OK");
            }
            catch (Exception e) //On Error Do
            {
                throw;
            }
        }