/// <summary> /// Enters the specified value for the specified workflow prompt. /// </summary> /// <param name="prompt">The prompt.</param> /// <param name="value">The value.</param> public void EnterPromptValue(string prompt, string value) { WidgetCollection widgets = _controlPanel.GetWidgets(); IEnumerable <string> prompts = widgets.OfType(WidgetType.Prompt).Select(n => n.Text); // Find the text box for the prompt and press it to navigate to the keyboard screen string promptMatch = StringMatcher.FindBestMatch(prompt, prompts, StringMatch.Contains, ignoreCase: true, ignoreWhiteSpace: true); if (promptMatch != null) { Widget label = widgets.Find(promptMatch); PressPrompt(widgets, label); _controlPanel.WaitForScreen(_workflowKeyboard, TimeSpan.FromSeconds(5)); Pacekeeper.Sync(); // Enter the parameter text, then navigate back to the parameter screen _controlPanel.TypeOnVirtualKeyboard(value); Pacekeeper.Sync(); _controlPanel.Press("OK"); _controlPanel.WaitForScreen(_workflowMain, TimeSpan.FromSeconds(5)); Pacekeeper.Sync(); } else { throw new DeviceWorkflowException($"Could not find workflow prompt '{prompt}'."); } }
private void PressPrompt(WidgetCollection widgets, Widget label) { if (ArePromptLocationsCorrect(widgets)) { Widget promptBox = widgets.FindByLabel(label, WidgetType.Button); _controlPanel.Press(promptBox); } else { if (AreTextBoxLocationsCorrect(widgets)) { // For some devices, the workflow parameters screen reports the same bounding box for each label, which // makes it impossible to determine which label corresponds to which text box by comparing their position. // Instead, we are forced to make an assumption based on the way the controls are dynamically created: // each text box corresponds to the prompt with an ID exactly 1 greater than the box's ID. _controlPanel.Press(label.Id - 1); } else { // On the workflow parameters screen, the bounding boxes are the same for all the labels AND text boxes. // We'll need to make some assumptions about the way the controls are dynamically created: // Each text box corresponds to the prompt with an ID exactly 1 greater than the box's ID, // AND the text box IDs are in ascending order as we move down the screen. int textBoxId = label.Id - 1; // Calculate the y offset from the top box's press coordinate. // There are 50 pixels between each edit box and the ID increments by 2 for each box. // The top box always has ID 1500 Widget topBox = widgets.Find(1500); var topBoxCenter = new Coordinate(topBox.Location.X + topBox.Size.Width / 2, topBox.Location.Y + topBox.Size.Height / 2); int offset = (textBoxId - topBox.Id) / 2 * 50; _controlPanel.PressScreen(new Coordinate(topBoxCenter.X, topBoxCenter.Y + offset)); } } }
/// <summary> /// Enables email notification for this job. /// </summary> /// <param name="condition">The condition under which to send notification.</param> /// <param name="address">The email address to receive the notification.</param> /// <param name="thumbNail">if set to<c>true>enable thumbnail;otherwise,disable it</c></param>//We have added thumbnail parameter but not yet implemented it public void EnableEmailNotification(NotifyCondition condition, string address, bool thumbNail) { Widget serviceButton = ScrollToOption("Notification"); Pacekeeper.Sync(); _controlPanel.Press(serviceButton); Pacekeeper.Sync(); // Press the notify option, then wait for the other widgets to load string notifyOption = (condition == NotifyCondition.OnlyIfJobFails ? "On error" : "This job"); _controlPanel.Press(notifyOption); Thread.Sleep(TimeSpan.FromSeconds(1)); Pacekeeper.Sync(); // On some devices (digital senders) this widget doesn't exist, since only email is available WidgetCollection widgets = _controlPanel.GetWidgets(); Widget emailWidget = widgets.Find("E-mail"); if (emailWidget != null) { _controlPanel.Press(emailWidget); Pacekeeper.Sync(); } // Enter the email address Widget label = widgets.Find("E-mail Address", StringMatch.StartsWith); Widget emailStringBox = widgets.FindByLabel(label, WidgetType.StringBox); _controlPanel.Press(emailStringBox); Pacekeeper.Sync(); _controlPanel.PressKey(OzHardKey.Clear); _controlPanel.TypeOnVirtualKeyboard(address); Pacekeeper.Sync(); _controlPanel.Press("OK"); Thread.Sleep(TimeSpan.FromSeconds(1)); Pacekeeper.Sync(); _controlPanel.Press("OK"); Pacekeeper.Sync(); }