public void SetupInfrastructure() { var metadata = new ScenarioMetadata { FeatureName = FeatureContext.FeatureInfo.Title, ScenarioName = ScenarioContext.ScenarioInfo.Title }; Register(metadata); var factory = new PossumLabs.Specflow.Core.Variables.ObjectFactory(); Register(factory); Register(new PossumLabs.Specflow.Core.Variables.Interpeter(factory)); var logger = new DefaultLogger(new DirectoryInfo(Environment.CurrentDirectory)); Register((PossumLabs.Specflow.Core.Logging.ILog)logger); Register(new PossumLabs.Specflow.Core.Exceptions.ActionExecutor(logger)); Register(new FileManager(new DatetimeManager() { Now = () => DateTime.Now })); FileManager.Initialize(FeatureContext.FeatureInfo.Title, ScenarioContext.ScenarioInfo.Title, null /*Specflow limitation*/); var templateManager = new PossumLabs.Specflow.Core.Variables.TemplateManager(); templateManager.Initialize(Assembly.GetExecutingAssembly()); Register(templateManager); Log.Message($"feature: {FeatureContext.FeatureInfo.Title} scenario: {ScenarioContext.ScenarioInfo.Title} \n" + $"Tags: {FeatureContext.FeatureInfo.Tags.LogFormat()} {ScenarioContext.ScenarioInfo.Tags.LogFormat()}"); }
public void Initialize() { DataCreatorFactory = new DataCreatorFactory(); var factory = new PossumLabs.Specflow.Core.Variables.ObjectFactory(); var interperter = new PossumLabs.Specflow.Core.Variables.Interpeter(factory); var templateManager = new PossumLabs.Specflow.Core.Variables.TemplateManager(); templateManager.Initialize(Assembly.GetExecutingAssembly()); Setup = new Setup(DataCreatorFactory, factory, templateManager, interperter); }
public void SetupInfrastructure() { var metadata = new ScenarioMetadata { FeatureName = FeatureContext.FeatureInfo.Title, ScenarioName = ScenarioContext.ScenarioInfo.Title }; Register(metadata); var factory = new PossumLabs.Specflow.Core.Variables.ObjectFactory(); Register(factory); Register(new PossumLabs.Specflow.Core.Variables.Interpeter(factory)); var logger = new DefaultLogger(new DirectoryInfo(Environment.CurrentDirectory)); Register((PossumLabs.Specflow.Core.Logging.ILog)logger); var templateManager = new PossumLabs.Specflow.Core.Variables.TemplateManager(); templateManager.Initialize(Assembly.GetExecutingAssembly()); Register(templateManager); }
protected virtual void SetupInfrastructure() { IConfiguration config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables() .Build(); NetworkWatcher = new NetworkWatcher(); var configFactory = new ConfigurationFactory(config); ObjectContainer.RegisterInstanceAs(configFactory.Create <MovieLoggerConfig>()); ObjectContainer.RegisterInstanceAs(configFactory.Create <ImageLoggingConfig>()); WebElementSourceLog = new WebElementSourceLog(); ImageLogging = new ImageLogging(ObjectContainer.Resolve <ImageLoggingConfig>()); Register(new FileManager(new DatetimeManager(() => DateTime.Now))); FileManager.Initialize(FeatureContext.FeatureInfo.Title, ScenarioContext.ScenarioInfo.Title, null /*Specflow limitation*/); MovieLogger = new MovieLogger(FileManager, ObjectContainer.Resolve <MovieLoggerConfig>(), Metadata); ObjectContainer.RegisterInstanceAs(ImageLogging); ObjectContainer.RegisterInstanceAs(MovieLogger); Logger = new DefaultLogger(new DirectoryInfo(Environment.CurrentDirectory), new YamlLogFormatter()); Register((PossumLabs.Specflow.Core.Logging.ILog)Logger); Register <ElementFactory>(new ElementFactory()); Register <XpathProvider>(new XpathProvider()); Register <SelectorFactory>(new SelectorFactory(ElementFactory, XpathProvider).UseBootstrap()); Register(new PossumLabs.Specflow.Selenium.WebDriverManager( this.Interpeter, this.ObjectFactory, new SeleniumGridConfiguration())); var dataGeneratorRepository = new DataGeneratorRepository(Interpeter, ObjectFactory); Register <DataGenerator>(dataGeneratorRepository.BuildGenerator()); var templateManager = new PossumLabs.Specflow.Core.Variables.TemplateManager(); templateManager.Initialize(Assembly.GetExecutingAssembly()); Register(templateManager); Log.Message($"feature: {FeatureContext.FeatureInfo.Title} scenario: {ScenarioContext.ScenarioInfo.Title} \n" + $"Tags: {FeatureContext.FeatureInfo.Tags.LogFormat()} {ScenarioContext.ScenarioInfo.Tags.LogFormat()}"); System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); WebDriverManager.Initialize(BuildDriver); WebDriverManager.WebDriverFactory = () => { var options = new ChromeOptions(); //grid options.AddAdditionalCapability("username", WebDriverManager.SeleniumGridConfiguration.Username, true); options.AddAdditionalCapability("accessKey", WebDriverManager.SeleniumGridConfiguration.AccessKey, true); var driver = new RemoteWebDriver(new Uri(WebDriverManager.SeleniumGridConfiguration.Url), options.ToCapabilities(), TimeSpan.FromSeconds(180)); //do not change this, the site is a bloody nightmare with overlaying buttons etc. driver.Manage().Window.Size = WebDriverManager.DefaultSize; var allowsDetection = driver as IAllowsFileDetection; if (allowsDetection != null) { allowsDetection.FileDetector = new LocalFileDetector(); } return(driver); }; }
public void SetupInfrastructure() { IConfiguration config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables() .Build(); var configFactory = new ConfigurationFactory(config); ObjectContainer.RegisterInstanceAs(configFactory.Create <MovieLoggerConfig>()); ObjectContainer.RegisterInstanceAs(configFactory.Create <ImageLoggingConfig>()); Register(new FileManager(new DatetimeManager(() => DateTime.Now))); ImageLogging = new ImageLogging(ObjectContainer.Resolve <ImageLoggingConfig>()); MovieLogger = new MovieLogger(FileManager, ObjectContainer.Resolve <MovieLoggerConfig>(), Metadata); ObjectContainer.RegisterInstanceAs(ImageLogging); ObjectContainer.RegisterInstanceAs(MovieLogger); var logger = new DefaultLogger(new DirectoryInfo(Environment.CurrentDirectory)); Register((PossumLabs.Specflow.Core.Logging.ILog)logger); Register <ElementFactory>(new ElementFactory()); Register <XpathProvider>(new XpathProvider()); Register <SelectorFactory>(new SelectorFactory(ElementFactory, XpathProvider).UseBootstrap()); Register(new PossumLabs.Specflow.Selenium.WebDriverManager( this.Interpeter, this.ObjectFactory, new SeleniumGridConfiguration())); FileManager.Initialize(FeatureContext.FeatureInfo.Title, ScenarioContext.ScenarioInfo.Title, null /*Specflow limitation*/); var templateManager = new PossumLabs.Specflow.Core.Variables.TemplateManager(); templateManager.Initialize(Assembly.GetExecutingAssembly()); Register(templateManager); Log.Message($"feature: {FeatureContext.FeatureInfo.Title} scenario: {ScenarioContext.ScenarioInfo.Title} \n" + $"Tags: {FeatureContext.FeatureInfo.Tags.LogFormat()} {ScenarioContext.ScenarioInfo.Tags.LogFormat()}"); System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); WebDriverManager.Initialize(BuildDriver); WebDriverManager.WebDriverFactory = () => { var options = new ChromeOptions(); // https://stackoverflow.com/questions/22322596/selenium-error-the-http-request-to-the-remote-webdriver-timed-out-after-60-sec?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa options.AddArgument("no-sandbox"); //might be a fix :/ options.AddArgument("disable-popup-blocking"); options.AddArgument("disable-gpu"); options.AddArgument("disable-extensions"); options.AddArgument("disable-dev-shm-usage"); options.AddAdditionalCapability("username", WebDriverManager.SeleniumGridConfiguration.Username, true); options.AddAdditionalCapability("accessKey", WebDriverManager.SeleniumGridConfiguration.AccessKey, true); //TODO: Config value var driver = new RemoteWebDriver(new Uri(WebDriverManager.SeleniumGridConfiguration.Url), options.ToCapabilities(), TimeSpan.FromSeconds(180)); //do not change this, the site is a bloody nightmare with overlaying buttons etc. driver.Manage().Window.Size = WebDriverManager.DefaultSize; var allowsDetection = driver as IAllowsFileDetection; if (allowsDetection != null) { allowsDetection.FileDetector = new LocalFileDetector(); } return(driver); }; }