public static IServiceCollection AddPageTesting <TUser>( this IServiceCollection services, Action <PageTestingConfig> setupAction = null) where TUser : UserfyUser { var config = new PageTestingConfig() { Services = services }; if (setupAction != null) { setupAction(config); services.AddSingleton(config); } services.AddSingleton <PageTestFixture>(); services.ReplaceSingleton <IUrlMaps, DefaultUrlMaps>(); services.AddSingleton <IStartupFilter, PageTestingStartupFilter>(); services.AddTransient <IUserSession, TestingUserSession <TUser> >(); services.AddSingleton <Storage>(); services.AddSingleton <PageBody>(); services.AddSingleton(sp => new WebDriverWait( sp.GetService <RemoteWebDriver>(), sp.GetService <PageTestingConfig>().TimeOut)); return(services); }
public PageTestFixture( IMiruApp app, UrlLookup urlLookup, PageTestingConfig config, RemoteWebDriver driver, IStorage storage, PageBody browser, MiruNavigator navigator) : base(navigator) { App = app; _urlLookup = urlLookup; _config = config; _driver = driver; _storage = storage; _browser = browser; _browser.BaseUrl = _config.BaseUrl; navigator.ConfigureExceptions(context => { var exceptionMessage = $@"{context.FailureMessage.Or(context.OriginalException.Message)} The url was: {Url} A screenshot was taken on the moment of the failure: {FailureScreenshot()} The Page's html has been saved to: {SaveHtml()} "; throw new PageTestException(exceptionMessage, context.OriginalException); }); }