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 LambdaTestAttribute( BrowserType browser, string browserVersion, string platform, DesktopWindowSize desktopWindowSize, string geoLocation, Lifecycle behavior = Lifecycle.NotSet, bool recordVideo = false, bool recordScreenshots = false, bool shouldAutomaticallyScrollToVisible = true) : this(browser, browserVersion, platform, behavior, recordVideo, recordScreenshots, shouldAutomaticallyScrollToVisible) { ScreenResolution = WindowsSizeResolver.GetWindowSize(desktopWindowSize).ConvertToString(); GeoLocation = geoLocation; }
private BrowserConfiguration GetCurrentBrowserConfiguration(MemberInfo memberInfo, Type testClassType, ServicesCollection container, List <object> arguments) { var browserAttribute = GetBrowserAttribute(memberInfo, testClassType); string fullClassName = testClassType.FullName; if (browserAttribute != null) { BrowserType currentBrowserType = browserAttribute.Browser; Lifecycle currentLifecycle = browserAttribute.Lifecycle; bool shouldCaptureHttpTraffic = browserAttribute.ShouldCaptureHttpTraffic; bool shouldAutomaticallyScrollToVisible = browserAttribute.ShouldAutomaticallyScrollToVisible; Size currentBrowserSize = browserAttribute.Size; ExecutionType executionType = browserAttribute.ExecutionType; var options = (browserAttribute as IDriverOptionsAttribute)?.CreateOptions(memberInfo, testClassType) ?? GetDriverOptionsBasedOnBrowser(currentBrowserType, testClassType); InitializeCustomCodeOptions(options, testClassType); var browserConfiguration = new BrowserConfiguration(executionType, currentLifecycle, currentBrowserType, currentBrowserSize, fullClassName, shouldCaptureHttpTraffic, shouldAutomaticallyScrollToVisible, options); container.RegisterInstance(browserConfiguration, "_currentBrowserConfiguration"); return(browserConfiguration); } else { BrowserType currentBrowserType = Parse <BrowserType>(ConfigurationService.GetSection <WebSettings>().ExecutionSettings.DefaultBrowser); if (arguments != null & arguments.Any()) { if (arguments[0] is BrowserType) { currentBrowserType = (BrowserType)arguments[0]; } } Lifecycle currentLifecycle = Parse <Lifecycle>(ConfigurationService.GetSection <WebSettings>().ExecutionSettings.DefaultLifeCycle); Size currentBrowserSize = default; if (!string.IsNullOrEmpty(ConfigurationService.GetSection <WebSettings>().ExecutionSettings.Resolution)) { currentBrowserSize = WindowsSizeResolver.GetWindowSize(ConfigurationService.GetSection <WebSettings>().ExecutionSettings.Resolution); } ExecutionType executionType = ConfigurationService.GetSection <WebSettings>().ExecutionSettings.ExecutionType.ToLower() == "regular" ? ExecutionType.Regular : ExecutionType.Grid; bool shouldCaptureHttpTraffic = ConfigurationService.GetSection <WebSettings>().ShouldCaptureHttpTraffic; bool shouldAutomaticallyScrollToVisible = ConfigurationService.GetSection <WebSettings>().ShouldAutomaticallyScrollToVisible; var options = GetDriverOptionsBasedOnBrowser(currentBrowserType, testClassType); if (!string.IsNullOrEmpty(ConfigurationService.GetSection <WebSettings>().ExecutionSettings.BrowserVersion)) { options.BrowserVersion = ConfigurationService.GetSection <WebSettings>().ExecutionSettings.BrowserVersion; } if (arguments != null & arguments.Count >= 2) { if (arguments[0] is BrowserType && arguments[1] is int) { options.BrowserVersion = arguments[1].ToString(); } } InitializeGridOptionsFromConfiguration(options, testClassType); InitializeCustomCodeOptions(options, testClassType); var browserConfiguration = new BrowserConfiguration(executionType, currentLifecycle, currentBrowserType, currentBrowserSize, fullClassName, shouldCaptureHttpTraffic, shouldAutomaticallyScrollToVisible, options); container.RegisterInstance(browserConfiguration, "_currentBrowserConfiguration"); return(browserConfiguration); } }
public AppAttribute(string appPath, DesktopWindowSize desktopWindowSize, Lifecycle behavior = Lifecycle.NotSet) : this(appPath, behavior) { AppConfiguration.Size = WindowsSizeResolver.GetWindowSize(desktopWindowSize); }
public AppAttribute(string appPath, TabletWindowSize tabletWindowSize, AppBehavior behavior = AppBehavior.NotSet) : this(appPath, behavior) { AppConfiguration.Size = WindowsSizeResolver.GetWindowSize(tabletWindowSize); }
private BrowserConfiguration GetCurrentBrowserConfiguration(Bellatrix.Plugins.PluginEventArgs e) { var browserAttribute = GetBrowserAttribute(e.TestMethodMemberInfo, e.TestClassType); string fullClassName = e.TestClassType.FullName; if (browserAttribute != null) { BrowserType currentBrowserType = browserAttribute.Browser; Lifecycle currentLifecycle = browserAttribute.Lifecycle; bool shouldCaptureHttpTraffic = browserAttribute.ShouldCaptureHttpTraffic; bool shouldAutomaticallyScrollToVisible = browserAttribute.ShouldAutomaticallyScrollToVisible; Size currentBrowserSize = browserAttribute.Size; ExecutionType executionType = browserAttribute.ExecutionType; var options = (browserAttribute as IDriverOptionsAttribute)?.CreateOptions(e.TestMethodMemberInfo, e.TestClassType) ?? GetDriverOptionsBasedOnBrowser(currentBrowserType, e.TestClassType); InitializeCustomCodeOptions(options, e.TestClassType); var browserConfiguration = new BrowserConfiguration(executionType, currentLifecycle, currentBrowserType, currentBrowserSize, fullClassName, shouldCaptureHttpTraffic, shouldAutomaticallyScrollToVisible, options); e.Container.RegisterInstance(browserConfiguration, "_currentBrowserConfiguration"); return(browserConfiguration); } else { BrowserType currentBrowserType = Parse <BrowserType>(ConfigurationService.GetSection <WebSettings>().ExecutionSettings.DefaultBrowser); if (e.Arguments != null & e.Arguments.Any()) { if (e.Arguments[0] is BrowserType) { currentBrowserType = (BrowserType)e.Arguments[0]; } } Lifecycle currentLifecycle = Parse <Lifecycle>(ConfigurationService.GetSection <WebSettings>().ExecutionSettings.DefaultLifeCycle); Size currentBrowserSize = default; if (!string.IsNullOrEmpty(ConfigurationService.GetSection <WebSettings>().ExecutionSettings.Resolution)) { currentBrowserSize = WindowsSizeResolver.GetWindowSize(ConfigurationService.GetSection <WebSettings>().ExecutionSettings.Resolution); } ExecutionType executionType = ConfigurationService.GetSection <WebSettings>().ExecutionSettings.ExecutionType.ToLower() == "regular" ? ExecutionType.Regular : ExecutionType.Grid; bool shouldCaptureHttpTraffic = ConfigurationService.GetSection <WebSettings>().ShouldCaptureHttpTraffic; bool shouldAutomaticallyScrollToVisible = ConfigurationService.GetSection <WebSettings>().ShouldAutomaticallyScrollToVisible; var options = GetDriverOptionsBasedOnBrowser(currentBrowserType, e.TestClassType); if (!string.IsNullOrEmpty(ConfigurationService.GetSection <WebSettings>().ExecutionSettings.BrowserVersion)) { options.BrowserVersion = ConfigurationService.GetSection <WebSettings>().ExecutionSettings.BrowserVersion; } if (e.Arguments != null & e.Arguments.Count >= 2) { if (e.Arguments[0] is BrowserType && e.Arguments[1] is int) { options.BrowserVersion = e.Arguments[1].ToString(); } } string testName = e.TestFullName != null?e.TestFullName.Replace(" ", string.Empty).Replace("(", string.Empty).Replace(")", string.Empty).Replace(",", string.Empty).Replace("\"", string.Empty) : e.TestClassType.FullName; InitializeGridOptionsFromConfiguration(options, e.TestClassType, testName); InitializeCustomCodeOptions(options, e.TestClassType); var browserConfiguration = new BrowserConfiguration(executionType, currentLifecycle, currentBrowserType, currentBrowserSize, fullClassName, shouldCaptureHttpTraffic, shouldAutomaticallyScrollToVisible, options); e.Container.RegisterInstance(browserConfiguration, "_currentBrowserConfiguration"); return(browserConfiguration); } }