public void SelectWorkflow(string workflowName) { _engine.ExecuteJavaScript(DssWorkflowResource.DssWorkflowJavaScript); // Select the first menu (arbitrarily) string firstMenu = "document.getElementById('rootAppListBox').getElementsByTagName('li')[0]"; BoundingBox boundingBox = _engine.GetElementBoundingArea(firstMenu); _engine.PressElementByBoundingArea(boundingBox); // Select the workflow try { DssWorkflowsReady(workflowName); _engine.ExecuteJavaScript(DssWorkflowResource.DssWorkflowJavaScript); PressElementByText("rootAppListBox", "li", workflowName); } catch (JavaScriptExecutionException) { throw new DeviceWorkflowException($"Unable to select workflow named '{workflowName}'."); } // Wait for the prompts to load _engine.WaitForHtmlContains("promptListBox", TimeSpan.FromSeconds(30)); }
/// <summary> /// Presses the given control. /// </summary> /// <param name="objectId">string</param> private void PressElement(string objectId) { BoundingBox boundingBox = _engine.GetBoundingAreaById(objectId); if (boundingBox.Left == 0 && boundingBox.Right == 0) { boundingBox = _engine.GetBoundingAreaById(objectId); } _engine.PressElementByBoundingArea(boundingBox); }
/// <summary> /// Enters credentials on the device by entering the PIN. /// </summary> public override void EnterCredentials() { string codeTextboxId = (_hpacVersion16_6 == true) ? _codeTextBox[1] : _codeTextBox[0]; BoundingBox box = _engine.GetBoundingAreaById(codeTextboxId); _engine.PressElementByBoundingArea(box); ControlPanel.Type(Credential.Pin); ControlPanel.WaitForControl("ok", TimeSpan.FromSeconds(5)); ControlPanel.Press("ok"); }
/// <summary> /// Press Element by Text /// </summary> protected void PressElementByText(string parentId, string tag, string text) { string elementWithText = $"getElementByText('{parentId}','{tag}','{text}')"; BoundingBox boundingBox = _engine.GetElementBoundingArea(elementWithText); _engine.PressElementByBoundingArea(boundingBox); }
/// <summary> /// Finds a valid element in the specified element list and presses it using the OxpdBrowserEngine. /// </summary> /// <param name="elementIds"></param> protected void PressElementOxpd(List <string> elementIds) { OxpdBrowserEngine engine = new OxpdBrowserEngine(ControlPanel); BoundingBox boundingBox = new BoundingBox(); for (int i = 0; i < elementIds.Count; i++) { try { boundingBox = engine.GetBoundingAreaById(elementIds[i]); break; // Found the element so stop iterating the list } catch (DeviceWorkflowException) { if (i == elementIds.Count - 1) { //If this is the last element, rethrow the exception throw; } } } engine.PressElementByBoundingArea(boundingBox); }