/// <summary> /// Test all links on the Krossover home page /// </summary> public void testHomePage(FirefoxDriver driver) { string homePage = "http://www.krossover.com/"; driver.Navigate().GoToUrl(homePage); Thread.Sleep(1000); //find all links on the page IList<IWebElement> links = driver.FindElementsByTagName("a"); //loop through all of the links on the page foreach (IWebElement link in links) { try { //check if any of the links return a 404 link.SendKeys(Keys.Control + Keys.Enter); driver.SwitchTo().Window(driver.WindowHandles.Last()); driver.FindElementByXPath("//div[contains(@class, '404')]"); log(link.GetAttribute("href") + " is broken. Returned 404"); driver.SwitchTo().Window(driver.WindowHandles.First()); } catch { //continue to the next link continue; } } driver.Quit(); //kill the driver }