private void ExecuteAdditionalCommands(ICommandAdapter adapter) { _additionalCommands = this.ParameterValue("AdditionalCommands", true); if (!_additionalCommands) { return; } if (this.ParameterValue(ToggleNavigationCommand.Name, true)) { var toggleNavigationCommand = new ToggleNavigationCommand(); toggleNavigationCommand.Execute(adapter); } var activeWindowSize = this.ParameterValue("ActiveWindowSize", _defaultWindowSize); var resizeWindowCommand = new ResizeWindowCommand(); resizeWindowCommand.Parameters.MainParameter = new MainParameter( $"{activeWindowSize.Width}x{activeWindowSize.Height}"); resizeWindowCommand.Execute(adapter); if (this.ParameterValue(HideCursorCommand.Name, true)) { var hideCaretCommand = new HideCursorCommand(); hideCaretCommand.Execute(adapter); } if (this.ParameterValue(KillFocusCommand.Name, true)) { var helperAutomation = new HelperAutomation(); Win32Declares.Message.SendMessage(helperAutomation.GetFocusControlHandle(), Win32Declares.Message.EM_SETSEL, -1, 0); var hideCaretCommand = new KillFocusCommand(); hideCaretCommand.Execute(adapter); } var sendKeys = this.ParameterValue <string>("SendKeys"); if (!string.IsNullOrEmpty(sendKeys)) { var sendKeysCommand = new SendKeysCommand(); sendKeysCommand.Parameters.MainParameter = new MainParameter(sendKeys); sendKeysCommand.Execute(adapter); } Wait(adapter, 1000); }
protected override void InternalExecute(ICommandAdapter adapter) { EasyTestTracer.Tracer.LogText("MainParameter=" + Parameters.MainParameter.Value); var activeWindowControl = adapter.CreateTestControl(TestControlType.Dialog, ""); var windowHandleInfo = GetWindowHandle(activeWindowControl); if (!windowHandleInfo.Value) { ExecuteAdditionalCommands(adapter); } GetRootWindow(windowHandleInfo.Key, adapter); var testImage = GetTestImage(windowHandleInfo.Key); var filename = GetFilename(adapter); var path = Path.GetDirectoryName(filename) + ""; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } try { if (File.Exists(filename)) { CompareAndSave(filename, testImage, adapter); } else { SaveActualImage(testImage, filename); throw new CommandException($"'{filename}' master copy was not found", StartPosition); } } finally { if (!windowHandleInfo.Value && this.ParameterValue(ToggleNavigationCommand.Name, true) && _additionalCommands) { var toggleNavigationCommand = new ToggleNavigationCommand(); toggleNavigationCommand.Execute(adapter); } } }