Example #1
0
        public static bool TestConnection(IWebDriver webDriver, TestProxyConfig testProxyConfig = null)
        {
            bool thereIsConnection = true;

            try
            {
                TestProxyConfig validTestProxyConfig = GetValidTestProxyConfig(testProxyConfig);

                WebDriverUtils.GoToUrl(webDriver, validTestProxyConfig.TestPageUrl);

                try
                {
                    FindElement(webDriver, validTestProxyConfig.Criteria);
                }
                catch (NoSuchElementException)
                {
                    thereIsConnection = false;
                }
            }
            catch (Exception)
            {
                thereIsConnection = false;
            }
            finally
            {
                if (webDriver != null)
                {
                    webDriver.Quit();
                }
            }

            return(thereIsConnection);
        }
Example #2
0
        private static TestProxyConfig GetValidTestProxyConfig(TestProxyConfig testProxyConfig)
        {
            if (testProxyConfig == null)
            {
                testProxyConfig = new TestProxyConfig()
                {
                    TestPageUrl = @"http://www.google.com.ar/",
                    Criteria    = new List <By>()
                    {
                        By.XPath("//body[@id='t']")
                    }
                };
            }

            return(testProxyConfig);
        }