public void TestInitialize()
        {
            var chromeDriverService = ChromeDriverService.CreateDefaultService(_assemblyFolder);
            var chromeOptions       = new ChromeOptions();

            if (ConfigurationService.Instance.GetLoadTestingSettings().IsEnabled&&
                ConfigurationService.Instance.GetWebProxySettings().IsEnabled)
            {
                _proxyService = new ProxyService();
                _loadTestingWorkflowPluginContext        = new LoadTestingWorkflowPluginContext();
                _proxyService.ProxyServer.BeforeRequest +=
                    _loadTestingWorkflowPluginContext.OnRequestCaptureTrafficEventHandler;
                _proxyService.Start();
                var webDriverProxy = new Proxy
                {
                    HttpProxy = $"http://127.0.0.1:{_proxyService.Port}",
                    SslProxy  = $"http://127.0.0.1:{_proxyService.Port}",
                };
                chromeOptions.Proxy = webDriverProxy;
            }

            Driver = new DriverAdapter(new ChromeDriver(chromeDriverService, chromeOptions));

            InitializeLoadTestingEngine();
        }
Exemple #2
0
        protected override void PreTestInit(object sender, TestWorkflowPluginEventArgs e)
        {
            var loadTestingAttribute             = GetOverridenAttribute <LoadTestAttribute>(e.TestMethodMemberInfo);
            var loadTestingWorkflowPluginContext = new LoadTestingWorkflowPluginContext();

            if (loadTestingAttribute == null)
            {
                loadTestingWorkflowPluginContext.IsLoadTestingEnabled = false;
            }
            else
            {
                loadTestingWorkflowPluginContext.IsLoadTestingEnabled = ConfigurationService.GetSection <LoadTestingSettings>().IsEnabled;
                loadTestingWorkflowPluginContext.ShouldFilterByHost   = loadTestingAttribute.ShouldRecordHostRequestsOnly;
                loadTestingWorkflowPluginContext.FilterHost           = loadTestingAttribute.Host;
            }

            loadTestingWorkflowPluginContext.CurrentTestName = e.TestFullName;

            e.Container.RegisterInstance(loadTestingWorkflowPluginContext);
            loadTestingWorkflowPluginContext.PreTestInit();

            base.PreTestInit(sender, e);
        }