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> /// Selects the first document in the document list. /// </summary> public void SelectFirstDocument(string checkboxId, string onchangeValue) { string docInfo = string.Empty; docInfo = "function selectDocument(){var elements = document.getElementsByTagName(\"input\"); for(var i = 0; i < elements.length; i++){ if(elements[i].type == \"checkbox\"){if(elements[i].id == \"" + checkboxId + "\"){elements[i].checked=\"checked\";" + onchangeValue + "} } } }selectDocument();"; _engine.ExecuteJavaScript(docInfo); }
private void CreateExistElementFunction() { _engine.ExecuteJavaScript(@"function ExistElementId(elementId) { var buttonElement = document.getElementById(elementId), existElement; existElement = true; if (buttonElement == null) { existElement = false; } return existElement; }"); }
/// <summary> /// Creates a javascript function for selecting the radio button in html. /// </summary> private void RadioButtonClickCreateFunction() { _engine.ExecuteJavaScript(@" function selectRadioButton(controlName, controlValue) { var bound = '0'; var allElements = document.getElementsByName(controlName); for (i = 0; i < allElements.length; i++) { if (allElements[i].value == controlValue) { allElements[i].click(); //allElements[i].focus(); break; } } }"); }
protected override void EnterDomain() { bool noOpException = true; try { if (WaitForHtmlContains("Domain", TimeSpan.FromMilliseconds(500))) { string script = $"document.getElementsByClassName('{_codeTextBoxClassname}')[2].value"; if (_engine.ExecuteJavaScript(script).Trim('"') == "") { noOpException = false; PressElementOxpdByClassIndex(_codeTextBoxClassname, 2); TypeOnVirtualKeyboard(Credential.Domain); Pacekeeper.Sync(); } } } catch (DeviceInvalidOperationException ex) { ExecutionServices.SystemTrace.LogDebug($"Unable to determine the existence of 'Domain' textbox. {ex.ToString()}"); // The intention here is to only throw a DeviceWorkflowException if the Domain textbox was detected AND failure occurred in entering the domain name. // All other failures in different locations (even while trying to detect if the domain textbox even exists) can just no-op. if (!noOpException) { throw new DeviceWorkflowException("Domain textbox was not found.", ex); } } }
/// <summary> /// Unselects all documents except the first. /// </summary> /// <param name="onClickValues">The javascript values (dynamically generated) for toggling the checkbox selection.</param> public virtual void SelectFirstDocument(Collection <string> onClickValues) { for (int i = 1; i < onClickValues.Count; i++) { _engine.ExecuteJavaScript(onClickValues[i]); } }
/// <summary> /// Checks if the given element ID exists on the current page /// </summary> /// <param name="elementText">Name of the element.</param> /// <return>true if exists</return> public bool ExistElementText(string elementText) { bool exist = false; string existId = _engine.ExecuteFunction("getElementIdbyTextContains", "div", elementText).Trim('"'); exist = (existId.Equals("undefined")) ? false : true; if (exist && elementText.Contains("Scan2")) { string value = string.Empty; try { // Calling into the OXPD browser too quick back to back can cause unexpected results... Thread.Sleep(250); value = _engine.ExecuteJavaScript($"document.getElementById('{existId}').textContent"); if (value.Contains("Native")) { exist = false; } } catch { value = string.Empty; } } return(exist); }
/// <summary> /// PerformJediHpacTasksOnCp /// </summary> /// <param name="action"></param> public void PerformJediHpacTasksOnCp(SolutionOperation action) { try { bool success = Wait.ForTrue( () => _jediDevice.ControlPanel.CurrentForm().StartsWith("OXP", StringComparison.OrdinalIgnoreCase), _longDelay); if (success) { // Get the document id - refer to SampleHpacPrint.html for example var results = GetDocumentsInfo(); string checkBoxId = ""; if (results != null) { checkBoxId = results.ElementAt(0).Id; } ExecutionServices.SystemTrace.LogDebug($"CheckBox Id of first print job: { (object)checkBoxId}"); //_engine.ExecuteJavaScript(HpacSelectFirstDocument); //Selects the First Document if (results != null) { switch (action) { case SolutionOperation.PrintKeep: { ClickById(checkBoxId, _shortDelay); ClickPrintJobsByName(PrintAndKeep); ClickById(PrintAndKeep, _shortDelay); } break; case SolutionOperation.PrintDelete: { ClickById(checkBoxId, _shortDelay); ClickPrintJobsByName(PrintAndDelete); ClickById(PrintAndDelete, _shortDelay); } break; case SolutionOperation.Print: { ClickById(checkBoxId, _shortDelay); ClickPrintJobsByName(PrintAll); ClickById(PrintAll, _shortDelay); } break; case SolutionOperation.Cancel: { ClickPrintJobsByName(PrintAll); ClickById(PrintAll, _mediumDelay); _jediDevice.ControlPanel.PressKey(JediHardKey.Menu); Thread.Sleep(_mediumDelay); _jediDevice.ControlPanel.PressToNavigate("mStopButton", "PauseDevicePopup", true); Thread.Sleep(TimeSpan.FromSeconds(15)); _jediDevice.ControlPanel.PressToNavigate("m_CancelButton", "TwoButtonMessageBox", true); Thread.Sleep(TimeSpan.FromSeconds(3)); _jediDevice.ControlPanel.Press("m_OKButton"); } break; case SolutionOperation.PrintAll: { ClickById(PrintAll, _shortDelay); } break; case SolutionOperation.UIValidation: { string result = _engine.ExecuteJavaScript(this.CheckButtonRefreshValue); if (result.ToLower() == "\"true\"") { ClickById(checkBoxId, _shortDelay); var res = _engine.ExecuteJavaScript(this.CheckButtonDeleteValue); { if (res.ToLower() == "\"false\"") { throw new Exception("The button did not toggle to Delete"); } } } else { throw new Exception("The button did not toggle to Refresh"); } } break; default: { _jediDevice.ControlPanel.PressKey(JediHardKey.Menu); throw new Exception($"{action} is not supported on Jedi devices"); } } //Press home sceeen _jediDevice.ControlPanel.PressKey(JediHardKey.Menu); _pacekeeper.Pause(); //Press on Signout _jediDevice.ControlPanel.Press("mSignInButton"); } } } catch (Exception ex) { ExecutionServices.SystemTrace.LogDebug(ex.Message); throw; } }