private AppInitializationInfo GetCurrentAppConfiguration(MemberInfo memberInfo, Type testClassType, ServicesCollection container) { var appAttribute = GetAppAttribute(memberInfo, testClassType); if (appAttribute != null) { container.RegisterInstance(appAttribute.AppConfiguration, "_currentAppConfiguration"); appAttribute.AppConfiguration.ClassFullName = testClassType.FullName; return(appAttribute.AppConfiguration); } else { Lifecycle currentLifecycle = Parse <Lifecycle>(ConfigurationService.GetSection <DesktopSettings>().ExecutionSettings.DefaultLifeCycle); Size currentAppSize = default; if (!string.IsNullOrEmpty(ConfigurationService.GetSection <DesktopSettings>().ExecutionSettings.Resolution)) { currentAppSize = WindowsSizeResolver.GetWindowSize(ConfigurationService.GetSection <DesktopSettings>().ExecutionSettings.Resolution); } var appConfiguration = new AppInitializationInfo { AppPath = ConfigurationService.GetSection <DesktopSettings>().ExecutionSettings.DefaultAppPath, Lifecycle = currentLifecycle, Size = currentAppSize, AppiumOptions = new DesiredCapabilities(), ClassFullName = testClassType.FullName, }; InitializeGridOptionsFromConfiguration(appConfiguration.AppiumOptions, testClassType); InitializeCustomCodeOptions(appConfiguration.AppiumOptions, testClassType); container.RegisterInstance(appConfiguration, "_currentAppConfiguration"); return(appConfiguration); } }
public AppAttribute(string appPath, Lifecycle lifecycle = Lifecycle.NotSet) { AppConfiguration = new AppInitializationInfo(); AppConfiguration.AppPath = appPath; AppConfiguration.Lifecycle = lifecycle; AppConfiguration.Size = default; AppConfiguration.AppiumOptioons = new AppiumOptions(); }
private void ResolvePreviousAppConfiguration(ServicesCollection childContainer) { var appConfiguration = new AppInitializationInfo(); if (childContainer.IsRegistered <AppInitializationInfo>()) { appConfiguration = childContainer.Resolve <AppInitializationInfo>(); } childContainer.RegisterInstance(appConfiguration, "_previousAppConfiguration"); }
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>(); }
public void StartApp(AppInitializationInfo appConfiguration, ServicesCollection childContainer) { try { var wrappedWebDriver = WrappedWebDriverCreateService.Create(appConfiguration, childContainer); childContainer.RegisterInstance <WindowsDriver <WindowsElement> >(wrappedWebDriver); ////childContainer.RegisterInstance(new AppService(wrappedWebDriver)); ////childContainer.RegisterInstance(new ComponentCreateService()); childContainer.RegisterNull <int?>(); childContainer.RegisterNull <IWebElement>(); childContainer.RegisterNull <WindowsElement>(); IsAppStartedCorrectly = true; } catch (Exception e) { e.PrintStackTrace(); IsAppStartedCorrectly = false; throw; } }
public static WindowsDriver <WindowsElement> Create(AppInitializationInfo appConfiguration, ServicesCollection childContainer) { var driverOptions = childContainer.Resolve <DesiredCapabilities>(appConfiguration.ClassFullName) ?? childContainer.Resolve <DesiredCapabilities>() ?? appConfiguration.AppiumOptions; driverOptions.SetCapability("app", appConfiguration.AppPath); driverOptions.SetCapability("deviceName", "WindowsPC"); driverOptions.SetCapability("platformName", "Windows"); string workingDir = Path.GetDirectoryName(appConfiguration.AppPath); driverOptions.SetCapability("appWorkingDir", workingDir); driverOptions.SetCapability("createSessionTimeout", ConfigurationService.GetSection <DesktopSettings>().TimeoutSettings.CreateSessionTimeout); driverOptions.SetCapability("ms:waitForAppLaunch", ConfigurationService.GetSection <DesktopSettings>().TimeoutSettings.WaitForAppLaunchTimeout); var additionalCapabilities = ServicesCollection.Main.Resolve <Dictionary <string, object> >($"caps-{appConfiguration.ClassFullName}") ?? new Dictionary <string, object>(); foreach (var additionalCapability in additionalCapabilities) { driverOptions.SetCapability(additionalCapability.Key, additionalCapability.Value); } var wrappedWebDriver = new WindowsDriver <WindowsElement>(new Uri(_serviceUrl), driverOptions); wrappedWebDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(ConfigurationService.GetSection <DesktopSettings>().TimeoutSettings.ImplicitWaitTimeout); ChangeWindowSize(appConfiguration.Size, wrappedWebDriver); wrappedWebDriver.SwitchTo().Window(wrappedWebDriver.CurrentWindowHandle); try { var closeButton = wrappedWebDriver.FindElementByAccessibilityId("Close"); wrappedWebDriver.Mouse.MouseMove(closeButton.Coordinates); } catch (Exception e) { e.PrintStackTrace(); } return(wrappedWebDriver); }