示例#1
0
        public string TakeScreenshotAndroidDriver(ServicesCollection container)
        {
            var        driver     = container.Resolve <AndroidDriver <AndroidElement> >();
            Screenshot screenshot = ((ITakesScreenshot)driver).GetScreenshot();

            return(screenshot.AsBase64EncodedString);
        }
 public void Dispose(ServicesCollection childContainer)
 {
     DisposeDriverService.DisposeAndroid(childContainer);
     DisposeDriverService.DisposeIOS(childContainer);
     DisposeDriverService.DisposeAndroid(ServicesCollection.Main);
     DisposeDriverService.DisposeIOS(ServicesCollection.Main);
 }
示例#3
0
 public void CloseApp(ServicesCollection childContainer)
 {
     DisposeDriverService.CloseAndroidApp(childContainer);
     DisposeDriverService.CloseIOSApp(childContainer);
     DisposeDriverService.CloseAndroidApp(ServicesCollection.Main);
     DisposeDriverService.CloseIOSApp(ServicesCollection.Main);
 }
示例#4
0
        public IMyShareOptions InitKernel()
        {
            TypeDict = TypeMap(MyShareConfig.Assemblies);

            ServicesCollection.AddMemoryCache();
            //添加CQRS服务
            ServicesCollection.AddSingleton(new InProcessBus());
            ServicesCollection.AddSingleton <ICommandSender>(y => y.GetService <InProcessBus>());
            ServicesCollection.AddSingleton <IEventPublisher>(y => y.GetService <InProcessBus>());
            ServicesCollection.AddSingleton <IHandlerRegistrar>(y => y.GetService <InProcessBus>());
            ServicesCollection.AddSingleton <ISerializer, Serializer>();
            ServicesCollection.AddSingleton(new DataContext(_options, TypeDict.Values.ToList()));

            ServicesCollection.AddScoped <ICache, MemoryCache>();
            ServicesCollection.AddSingleton <IEventStore, SampleEventStore>();
            ServicesCollection.AddScoped <IRepository, Repository>();
            ServicesCollection.AddScoped <ICacheRepository, CacheRepository>();
            ServicesCollection.AddScoped <ISession, Session>();


            //ServicesCollection.AddScoped<IRepository>(y => new CacheRepository(new Repository(y.GetService(typeof(IEventStore)) as IEventStore),
            //    y.GetService(typeof(IEventStore)) as IEventStore, y.GetService<ICache>()));

            RegHandlerType();

            return(this);
        }
示例#5
0
        public static void CloseAndroidApp(ServicesCollection childContainer)
        {
            var androidDriver = childContainer.Resolve <AndroidDriver <AndroidElement> >();

            androidDriver?.ResetApp();
            androidDriver?.CloseApp();
        }
示例#6
0
        public string TakeScreenshotVanillaWebDriver(ServicesCollection serviceContainer)
        {
            var        driver     = serviceContainer.Resolve <WindowsDriver <WindowsElement> >();
            Screenshot screenshot = ((ITakesScreenshot)driver).GetScreenshot();

            return(screenshot.AsBase64EncodedString);
        }
示例#7
0
        public static bool Init()
        {
            string fileName = invox.Options.BaseDirectory + XML_NAME;

            if (!File.Exists(fileName))
            {
                return(false);
            }

            using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) {
                if (!fs.CanRead)
                {
                    return(false);
                }

                XDocument x = XDocument.Load(fs);
                if (x.Root.Name != "items")
                {
                    Logger.Log("Неверное имя корневого элемента в справочнике " + XML_NAME);
                    return(false);
                }
                int year = DateTime.Today.Year;
                Service = new ServicesCollection(x.Root);
            }

            return(true);
        }
示例#8
0
        public void StartBrowser(BrowserConfiguration browserConfiguration, ServicesCollection childContainer)
        {
            try
            {
                var wrappedWebDriver = WrappedWebDriverCreateService.Create(browserConfiguration);

                childContainer.RegisterInstance <IWebDriver>(wrappedWebDriver);
                childContainer.RegisterInstance(((RemoteWebDriver)wrappedWebDriver).SessionId.ToString(), "SessionId");
                childContainer.RegisterInstance(ConfigurationService.GetSection <WebSettings>().ExecutionSettings.Url, "GridUri");

                ////childContainer.RegisterInstance(new BrowserService(wrappedWebDriver));
                ////childContainer.RegisterInstance(new CookiesService(wrappedWebDriver));
                ////childContainer.RegisterInstance(new DialogService(wrappedWebDriver));
                ////childContainer.RegisterInstance(new JavaScriptService(wrappedWebDriver));
                ////childContainer.RegisterInstance(new InteractionsService(wrappedWebDriver));
                ////childContainer.RegisterInstance(new NavigationService(wrappedWebDriver));
                ////childContainer.RegisterInstance(new ComponentCreateService());
                childContainer.RegisterInstance <IWebDriverElementFinderService>(new NativeElementFinderService(wrappedWebDriver));
                childContainer.RegisterNull <int?>();
                childContainer.RegisterNull <IWebElement>();
                IsBrowserStartedCorrectly = true;
            }
            catch
            {
                IsBrowserStartedCorrectly = false;
                throw;
            }
        }
示例#9
0
        public string TakeScreenshotIOSDriver(ServicesCollection serviceContainer)
        {
            var driver     = serviceContainer.Resolve <IOSDriver <IOSElement> >();
            var screenshot = ((ITakesScreenshot)driver).GetScreenshot();

            return(screenshot.AsBase64EncodedString);
        }
        public string TakeScreenshotHtml2Canvas(ServicesCollection serviceContainer)
        {
            var html2CanvasContent = GetEmbeddedResource("html2canvas.js", Assembly.GetExecutingAssembly());
            var javaScriptService  = serviceContainer.Resolve <JavaScriptService>();
            var wait = new WebDriverWait(javaScriptService.WrappedDriver, TimeSpan.FromSeconds(60));

            wait.IgnoreExceptionTypes(typeof(InvalidOperationException));
            wait.IgnoreExceptionTypes(typeof(ArgumentNullException));

            javaScriptService.Execute(html2CanvasContent);
            javaScriptService.Execute(GenerateScreenshotJavaScript);
            wait.Until(
                wd =>
            {
                string response = (string)javaScriptService.Execute("return (typeof canvasImgContentDecoded === 'undefined' || canvasImgContentDecoded === null)");
                if (string.IsNullOrEmpty(response))
                {
                    return(false);
                }

                return(bool.Parse(response));
            });
            wait.Until(wd => !string.IsNullOrEmpty((string)javaScriptService.Execute("return canvasImgContentDecoded;")));
            var pngContent = (string)javaScriptService.Execute("return canvasImgContentDecoded;");

            pngContent = pngContent.Replace("data:image/png;base64,", string.Empty);
            return(pngContent);
        }
示例#11
0
        public static void DisposeIOS(ServicesCollection childContainer)
        {
            var iosDriver = childContainer.Resolve <IOSDriver <IOSElement> >();

            iosDriver?.CloseApp();
            iosDriver?.Quit();
            childContainer.UnregisterSingleInstance <IOSDriver <IOSElement> >();
        }
        private void ShutdownBrowser(ServicesCollection container)
        {
            // Disposing existing engine call only dispose if in parallel.
            var previousTestExecutionEngine = container.Resolve <TestExecutionEngine>();

            previousTestExecutionEngine?.Dispose(container);
            container.UnregisterSingleInstance <TestExecutionEngine>();
        }
示例#13
0
        public static void DisposeAndroid(ServicesCollection childContainer)
        {
            var androidDriver = childContainer.Resolve <AndroidDriver <AndroidElement> >();

            androidDriver?.CloseApp();
            androidDriver?.Quit();
            androidDriver?.Dispose();
            childContainer.UnregisterSingleInstance <AndroidDriver <AndroidElement> >();
        }
示例#14
0
        public static void Dispose(ServicesCollection childContainer)
        {
            var webDriver = childContainer.Resolve <WindowsDriver <WindowsElement> >();

            webDriver?.Quit();
            webDriver?.Dispose();
            childContainer.UnregisterSingleInstance <WindowsDriver <WindowsElement> >();
            ServicesCollection.Main.UnregisterSingleInstance <WindowsDriver <WindowsElement> >();
        }
示例#15
0
        private void ShutdownApp(ServicesCollection container)
        {
            DisposeDriverService.DisposeAndroid(container);
            DisposeDriverService.DisposeIOS(container);

            var currentAppConfiguration = container.Resolve <AppConfiguration>("_currentAppConfiguration");

            container.RegisterInstance(currentAppConfiguration, "_previousAppConfiguration");
        }
示例#16
0
        private void ResolvePreviousAppConfiguration(ServicesCollection childContainer)
        {
            var appConfiguration = new AppConfiguration();

            if (childContainer.IsRegistered <AppConfiguration>())
            {
                appConfiguration = childContainer.Resolve <AppConfiguration>();
            }

            childContainer.RegisterInstance(appConfiguration, "_previousAppConfiguration");
        }
示例#17
0
        private void ShutdownApp(ServicesCollection container)
        {
            DisposeDriverService.Dispose(container);
            var appConfiguration = new AppInitializationInfo();

            // BUG: If we use ReuseIfStarted, there is a new child container for each class and when
            // we initialize a new childcontainer the _previousAppConfiguration is missing and the app
            // is still opened. Probably this won't work in parallel.
            container.RegisterInstance(appConfiguration, "_previousAppConfiguration");
            ////container.UnregisterSingleInstance<TestExecutionEngine>();
        }
        private void ResolvePreviousBrowserType(ServicesCollection container)
        {
            bool shouldScrollToVisible = ConfigurationService.GetSection <WebSettings>().ShouldAutomaticallyScrollToVisible;
            var  browserConfiguration  = new BrowserConfiguration(BrowserType.NotSet, false, shouldScrollToVisible);

            if (container.IsRegistered <BrowserConfiguration>())
            {
                browserConfiguration = container.Resolve <BrowserConfiguration>();
            }

            container.RegisterInstance(browserConfiguration, "_previousBrowserConfiguration");
        }
示例#19
0
        private void SavedServicesRestart(object sender, EventArgs e)
        {
            if (Services == null)
            {
                return;
            }

            // Restart only running services.
            ServicesCollection runningServices = new ServicesCollection();

            runningServices.AddRange(from entry in Services.GetStatuses() where entry.Value == ServiceControllerStatus.Running select entry.Key);
            runningServices.InvokeRestart();
        }
 private void writeDatainList()
 {
     using (var db = new PSDBContext())
     {
         ServicesCollection.Clear();
         db.Services.Where(login => login.User.Login == userViewModel.UserLogin).ToList().ForEach(a =>
         {
             ServicesCollection.Add(new Service {
                 Title = a.Title
             });
         });
     }
 }
        private void ShutdownBrowser(ServicesCollection container)
        {
            // Disposing existing engine call only dispose if in parallel.
            var previousTestExecutionEngine = container.Resolve <TestExecutionEngine>();

            previousTestExecutionEngine?.DisposeAll();

            bool shouldScrollToVisible = ConfigurationService.GetSection <WebSettings>().ShouldAutomaticallyScrollToVisible;
            var  browserConfiguration  = new BrowserConfiguration(BrowserType.NotSet, false, shouldScrollToVisible);

            container.RegisterInstance(browserConfiguration, "_previousBrowserConfiguration");
            container.UnregisterSingleInstance <TestExecutionEngine>();
        }
示例#22
0
        private bool ShouldRestartApp(ServicesCollection container)
        {
            bool shouldRestartApp            = false;
            var  previousTestExecutionEngine = container.Resolve <TestExecutionEngine>();
            var  previousAppConfiguration    = container.Resolve <AppConfiguration>("_previousAppConfiguration");
            var  currentAppConfiguration     = container.Resolve <AppConfiguration>("_currentAppConfiguration");

            if (previousTestExecutionEngine == null || !previousTestExecutionEngine.IsAppStartedCorrectly || !currentAppConfiguration.Equals(previousAppConfiguration))
            {
                shouldRestartApp = true;
            }

            return(shouldRestartApp);
        }
示例#23
0
        private void ShutdownApp(ServicesCollection container)
        {
            var currentAppConfiguration = container.Resolve <AppConfiguration>("_currentAppConfiguration");

            ShutdownApp(container);

            // Register the ExecutionEngine that should be used for the current run. Will be used in the next test as PreviousEngineType.
            var testExecutionEngine = new TestExecutionEngine();

            // Register the app that should be used for the current run. Will be used in the next test as PreviousappType.
            container.RegisterInstance(currentAppConfiguration);

            // Start the current engine
            testExecutionEngine.StartApp(currentAppConfiguration, container);
        }
        public static void Dispose(IWebDriver webDriver, ServicesCollection container)
        {
            try
            {
                webDriver?.Quit();
                webDriver?.Dispose();
                container?.UnregisterSingleInstance <IWebDriver>();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }

            ProcessCleanupService.KillPreviousDriversAndBrowsersOsAgnostic(TestRunStartTime);
        }
示例#25
0
 public TopologyConfigurator(ServicesCollection services, HostingTreeBuilder treeBuilder,
                             CredentialsFormatter formatter)
 {
     this.services    = services;
     this.treeBuilder = treeBuilder;
     this.formatter   = formatter;
     try
     {
         LoadFromFile();
     }
     catch (Exception ex)
     {
         ColoredConsole.WriteLine(ConsoleColor.Red, $"Can`t load topology:\n{ex.GetType().Name}\n{ex.Message}\n{ex.StackTrace}");
     }
 }
示例#26
0
        public TopologyEditorForm(ServicesCollection services, Node <OAuthCredentials> input, Result <Node <OAuthCredentials> > result)
        {
            this.services = services;
            this.input    = input;
            this.result   = result;
            result.Value  = input?.Clone();

            InitializeControls();
            ok.Click     += (_, __) => Save();
            reset.Click  += (_, __) => Reset();
            cancel.Click += (_, __) => Cancel();

            ControlBox = false;

            Reset();
        }
示例#27
0
        public static void Dispose(IWebDriver webDriver, ServicesCollection container)
        {
            try
            {
                webDriver?.Close();
                webDriver?.Quit();
                webDriver?.Dispose();
                container?.UnregisterSingleInstance <IWebDriver>();
            }
            catch (Exception ex)
            {
                DebugInformation.PrintStackTrace(ex);
            }

            ProcessCleanupService.KillPreviousDriversAndBrowsersOsAgnostic(TestRunStartTime);
        }
        private void RestartBrowser(ServicesCollection container)
        {
            var currentBrowserConfiguration = container.Resolve <BrowserConfiguration>("_currentBrowserConfiguration");

            ShutdownBrowser(container);

            // Register the ExecutionEngine that should be used for the current run. Will be used in the next test as PreviousEngineType.
            var testExecutionEngine = new TestExecutionEngine();

            container.RegisterInstance(testExecutionEngine);

            // Register the Browser type that should be used for the current run. Will be used in the next test as PreviousBrowserType.
            container.RegisterInstance(currentBrowserConfiguration);

            // Start the current engine with current browser type.
            testExecutionEngine.StartBrowser(currentBrowserConfiguration, container);
        }
        public void writeDataWithDateTimeInTable()
        {
            using (var db = new PSDBContext())
            {
                AddressesCollection.Clear();
                db.Addresses.Where(login => login.User.Login == userViewModel.UserLogin).ToList().ForEach(ad =>
                                                                                                          AddressesCollection.Add(new Address
                {
                    Title = ad.Title
                })
                                                                                                          );

                ServicesCollection.Clear();
                db.Services.Where(login => login.User.Login == userViewModel.UserLogin).ToList().ForEach(ad =>
                                                                                                         ServicesCollection.Add(new Service
                {
                    Title = ad.Title
                })
                                                                                                         );

                RatesCollection.Clear();
                db.Rates.Where(login => login.User.Login == userViewModel.UserLogin).ToList().ForEach(ad =>
                                                                                                      RatesCollection.Add(new Rate
                {
                    Title        = ad.Title,
                    MeasureTitle = ad.MeasureTitle,
                    Price        = ad.Price.ToString()
                })
                                                                                                      );
                VICollection.Clear();
                db.VolumeIndications.Where(login => login.User.Login == userViewModel.UserLogin && login.DatePaid == SelectedDate).ToList().ForEach(vi =>
                                                                                                                                                    VICollection.Add(new VolumeIndication
                {
                    SelectedAddress = AddressesCollection.FirstOrDefault(adcol => adcol.Title == vi.Address.Title),
                    SelectedService = ServicesCollection.FirstOrDefault(adcol => adcol.Title == vi.Service.Title),
                    SelectedRate    = RatesCollection.FirstOrDefault(adcol => adcol.Title == vi.Rate.Title),
                    PrevIndication  = vi.PrevIndication.ToString(),
                    CurIndication   = vi.CurIndication.ToString(),
                    Total           = vi.Total.ToString(),
                    SelectedDate    = vi.DatePaid,
                    Id = vi.Id
                }
                                                                                                                                                                     ));
            }
        }
        private void RestartBrowser(ServicesCollection container)
        {
            if (_previousBrowserConfiguration.BrowserType != BrowserType.NotSet) // NotSet = initial browser start
            {
                ShutdownBrowser(container);
            }

            // Register the ExecutionEngine that should be used for the current run. Will be used in the next test as PreviousEngineType.
            var testExecutionEngine = new TestExecutionEngine();

            container.RegisterInstance(testExecutionEngine);

            // Register the Browser type that should be used for the current run. Will be used in the next test as PreviousBrowserType.
            container.RegisterInstance(_currentBrowserConfiguration);

            // Start the current engine with current browser type.
            testExecutionEngine.StartBrowser(_currentBrowserConfiguration, container);
        }