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 a given control from Object id and Object class name /// </summary> /// <param name="className">string</param> /// <param name="className2">string</param> private void PressElement(string className, string className2) { string script = $"document.getElementsByClassName('{className}')[0].getElementsByClassName('{className2}')[0]"; BoundingBox boundingBox = _engine.GetElementBoundingArea(script); if (boundingBox.Left == 0 && boundingBox.Right == 0) { boundingBox = _engine.GetElementBoundingArea(script); } _engine.PressElementByBoundingArea(boundingBox); }
/// <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); }