Bullet-proof Wait

Add the following to your Driver.cs file (as a new method).

        protected static IWebElement WaitForElement(By locator)
        {
            // Wait until this condition is met
            new WebDriverWait(Browser, TimeSpan.FromSeconds(30)).Until(condition =>
            {
                try
                {
                    // Ensure that at least one element is returned
                    return Browser.FindElements(locator).Count > 0;
                }
                // Ensure that the element isn't stale (i.e. the page has been refreshed)
                catch (StaleElementReferenceException)
                {
                    return false;
                }
                // Ensure that the element exists
                catch (NoSuchElementException)
                {
                    return false;
                }
            }
            );
            // Return the first element that is found
            return Browser.FindElements(locator).ElementAt(0);
        }

Now replace all your Browser.FindElement commands with the WaitForElement command in your LoginPage class and your ToolsPage class.


Running in IE

If you've tried adding an Internet Explorer case statement to your switch statement in the Driver.cs file, you'll need to add the following IE options to get it working.

var ieOptions = new InternetExplorerOptions();

ieOptions.IgnoreZoomLevel = true;
ieOptions.RequireWindowFocus = true;
ieOptions.EnableNativeEvents = false;
ieOptions.EnablePersistentHover = true;

Also in Internet Explorer change the following settings:


Internet Options > Security


Check the Enable Protected Mode (requires restarting Internet Explorer) text box for all the following profiles:

  1. Internet

  2. Local intranet

  3. Trusted Sites

  4. Restricted Sites