public ICommandProvider WithConfig(FluentSettings settings) { // If an alert is open, the world ends if we touch the size property. Ignore this and let it get set by the next command chain try { if (settings.WindowMaximized) { // store window size back before maximizing so we can 'undo' this action if necessary // this code intentionally touches this.Settings before its been replaced with the local // configuration code, so that when the With.___.Then block is completed, the outer settings // object has the correct window size to work with. var windowSize = webDriver.Manage().Window.Size; if (!this.Settings.WindowWidth.HasValue) { this.Settings.WindowWidth = windowSize.Width; } if (!this.Settings.WindowHeight.HasValue) { this.Settings.WindowHeight = windowSize.Height; } this.webDriver.Manage().Window.Maximize(); } // If the browser size has changed since the last config change, update it else if (settings.WindowWidth.HasValue && settings.WindowHeight.HasValue) { this.webDriver.Manage().Window.Size = new Size(settings.WindowWidth.Value, settings.WindowHeight.Value); } } catch (UnhandledAlertException) { } // added catch InvalidOperationException catch below to fix a serious problem; needs a functional test to prove this solves certain issues // was getting the following error when trying to switch back from a popup modal in Goblinfactory // possibly because the modal changes window size and there are alerts, ...however I was unable to create a simple // test to reproduce the behavior, and I needed an urgent fix. Must come back to this to work out what was really needed and exactly why? // ----------- // unknown error: unhandled inspector error: { "code":-32000,"message":"No target with given id"} // (Session info: chrome = 65.0.3325.181) // (Driver info: chromedriver = 2.37.544315(730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform = Windows NT 10.0.16299 x86_64) catch (InvalidOperationException) {} this.Settings = settings; return(this); }
public bool SaveScreenshot(FluentSettings settings, byte[] contents, string fileName) { try { if (!string.IsNullOrEmpty(settings.ScreenshotPrefix)) { fileName = settings.ScreenshotPrefix + fileName; } if (Path.GetExtension(fileName) != ".png") { fileName += ".png"; } File.WriteAllBytes(Path.Combine(settings.ScreenshotPath, fileName), contents); return(true); } catch (Exception) { return(false); } }
public FluentConfig Configure(FluentSettings settings) { FluentSettings.Current = settings; return(this); }
public WithSyntaxProvider(IActionSyntaxProvider actionSyntaxProvider) { this.actionSyntaxProvider = actionSyntaxProvider; this.inlineSettings = FluentSettings.Current.Clone(); }
public ICommandProvider WithConfig(FluentSettings settings) { Parallel.ForEach(this.commandProviders, x => x.WithConfig(settings)); return(this); }
internal ActionSyntaxProvider WithConfig(FluentSettings settings) { this.commandProvider.WithConfig(settings); this.settings = settings; return(this); }
public ActionSyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider, FluentSettings settings) { this.commandProvider = commandProvider.WithConfig(settings); this.assertProvider = assertProvider; this.settings = settings; }