Exemplo n.º 1
0
 static DriverProvider()
 {
     // Initialise static member variables
     Browser = Config.ReadSetting("Browser");
     Logger.Debug($"Browser set to: {Browser}");
     BrowserVersion = Config.ReadSetting("BrowserVersion");
     Logger.Debug($"Browser version set to: {BrowserVersion}");
     Platform = Config.ReadSetting("Platform");
     Logger.Debug($"Platform set to: {Platform}");
     Proxy = SetProxy();
     Grid  = Config.ReadSetting("Grid");
     Logger.Debug($"Grid set to: {Grid}");
 }
        public void CallingMethods()
        {
            CommonLogMock       logMock = new CommonLogMock();
            CommonLoggingLogger logger  = new CommonLoggingLogger(logMock);
            bool b = logger.IsDebugEnabled;

            b = logger.IsErrorEnabled;
            b = logger.IsFatalEnabled;
            b = logger.IsInfoEnabled;
            b = logger.IsWarnEnabled;

            logger.Debug(null);
            logger.Debug(null, null);
            logger.DebugFormat(null, null);

            logger.Error(null);
            logger.Error(null, null);
            logger.ErrorFormat(null, null);

            logger.Warn(null);
            logger.Warn(null, null);
            logger.WarnFormat(null, null);

            logger.Info(null);
            logger.Info(null, null);
            logger.InfoFormat(null, null);

            logger.Fatal(null);
            logger.Fatal(null, null);

            logMock.debug.Should().Be(1);
            logMock.debugException.Should().Be(1);
            logMock.debugFormat.Should().Be(1);
            logMock.info.Should().Be(1);
            logMock.infoException.Should().Be(1);
            logMock.infoFormat.Should().Be(1);
            logMock.warn.Should().Be(1);
            logMock.warnException.Should().Be(1);
            logMock.warnFormat.Should().Be(1);
            logMock.error.Should().Be(1);
            logMock.errorException.Should().Be(1);
            logMock.errorFormat.Should().Be(1);
            logMock.fatal.Should().Be(1);
            logMock.fatalException.Should().Be(1);
            logMock.isDebugEnabled.Should().Be(1);
            logMock.isInfoEnabled.Should().Be(1);
            logMock.isWarnEnabled.Should().Be(1);
            logMock.isErrorEnabled.Should().Be(1);
            logMock.isFatalEnabled.Should().Be(1);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Determines if a <paramref name="browser" /> is in the supported
        ///     list.
        /// </summary>
        /// <param name="browser">The name of the browser.</param>
        /// <returns>
        ///     The numeric value representing the <paramref name="browser" /> in
        ///     the <see langword="enum" /> or -1 if it is not supported
        /// </returns>
        public static bool IsSupported(string browser)
        {
            Logger.Debug($"Checking if {browser} is supported.");
            Browser supported;

            return(Enum.TryParse(browser, out supported));
        }
Exemplo n.º 4
0
        /// <summary>
        /// </summary>
        /// <param name="browser"></param>
        /// <exception cref="System.NotImplementedException" />
        /// <exception cref="System.ArgumentOutOfRangeException" />
        /// <returns>
        /// </returns>
        public static IWebDriver Init(SupportedBrowsers.Browser browser)
        {
            Logger.Debug($"Attempting to start browser: {browser}");
            IBrowserStrategy browserStrategy;

            switch (browser)
            {
            case SupportedBrowsers.Browser.Firefox:
                browserStrategy = new FirefoxStrategy();
                break;

            case SupportedBrowsers.Browser.Chrome:
                browserStrategy = new ChromeStrategy();
                break;

            case SupportedBrowsers.Browser.Iexplore:
                browserStrategy = new InternetExplorerStrategy();
                break;

            case SupportedBrowsers.Browser.Phantomjs:
                browserStrategy = new PhantomjsStrategy();
                break;

            case SupportedBrowsers.Browser.Chromeemulation:
                browserStrategy = new ChromeEmulationStrategy();
                break;

            case SupportedBrowsers.Browser.Edge:
                browserStrategy = new EdgeStrategy();
                break;

            case SupportedBrowsers.Browser.Opera:
            case SupportedBrowsers.Browser.Safari:
                throw new NotImplementedException();

            default:
                throw new ArgumentOutOfRangeException(nameof(browser), browser, null);
            }

            var webDriver = string.IsNullOrWhiteSpace(DriverProvider.Grid)
                ? browserStrategy.GetDriver()
                : new RemoteWebDriver(new Uri(DriverProvider.Grid), browserStrategy.GetOptions());

            Logger.Debug($"Started browser: {browser}");
            return(webDriver);
        }
Exemplo n.º 5
0
        /// -------------------------------------------------------------------------------------------------
        /// <summary>   Searches for the first element. </summary>
        /// <param name="by">   The by. </param>
        /// <returns>   The found element. </returns>
        /// -------------------------------------------------------------------------------------------------
        public IWebElement FindElement(By by)
        {
            Logger.Debug($"Finding element {by}");
            var element = WaitForElementToBePresent(Locator, Timeout);

            return(element.FindElement(by));
        }