/// <inheritdoc /> public void BeforeTest(ITest test) { this.log = this.CreateLogger(); var pageType = GetFixturePage(test); var configBuilder = test.Fixture as IProvideWebDriverConfigBuilder; var configHolder = test.Fixture as IRequireCurrentWebDriverConfig; var authentication = test.Fixture as IRequireAuthentication; var screenshots = test.Fixture as IRequireScreenshots; var downloads = test.Fixture as IRequireDownloadDirectory; var config = configBuilder?.Builder.Build() ?? WebDriver .Configure( builder => { builder.WithDefaultOptions(); if (downloads != null) { builder.DownloadDirectory(downloads.DownloadDirectory); } return(builder); }, log) .Build(); if (configHolder != null) { configHolder.Config = config; } /* lazy initialized */ authHelper = new AuthenticationHelper(config, log); var init = authentication != null ? (Action <IWebDriverConfig, IWebDriver, IAuthenticationHelper>)AuthenticatedInitialize : Initialize; ExceptionDispatchInfo initializationException = null; (webDriver, initializationException) = WebDriverFactory.CreateAndInitialize(config, (cfg, drv) => init(cfg, drv, authHelper)); initializationException?.Throw(); var requiresWebForPageType = RequiresWebType.MakeGenericType(pageType); var page = GetPage(pageType, config); requiresWebForPageType.GetProperty("StartPage")?.SetValue(test.Fixture, page); if (screenshots != null) { page.WaitForPageToLoad(); SaveScreenshotForEachTab(TestContext.CurrentContext, "_pre"); } }