コード例 #1
0
        /// <summary>
        /// Presses the application button.
        /// </summary>
        /// <param name="appName">The application name (used for logging).</param>
        /// <param name="appButton">The application button selector.</param>
        /// <param name="folderButton">The folder button selector, if the app button could be inside a home screen folder.</param>
        /// <param name="expectedDestination">The expected destination selector.</param>
        /// <returns><c>true</c> if the expected destination was reached, <c>false</c> otherwise.</returns>
        public bool PressAppButton(string appName, string appButton, string folderButton, string expectedDestination)
        {
            // Find the app button
            if (_controlPanel.CheckState(appButton, OmniElementState.Exists))
            {
                _controlPanel.ScrollToItem(appButton);
                Pacekeeper.Sync();
            }
            else if (folderButton != null && _controlPanel.CheckState(folderButton, OmniElementState.Exists))
            {
                _controlPanel.ScrollPress(folderButton);
                if (_controlPanel.WaitForState(appButton, OmniElementState.Exists, TimeSpan.FromSeconds(10)))
                {
                    Pacekeeper.Pause();
                    _controlPanel.ScrollToItem(appButton);
                    Pacekeeper.Sync();
                }
                else
                {
                    throw new DeviceWorkflowException($"{appName} application button was not found on device home screen or in standard folder.");
                }
            }
            else
            {
                throw new DeviceWorkflowException($"{appName} application button was not found on device home screen.");
            }

            // Press the app button
            RecordEvent(DeviceWorkflowMarker.AppButtonPress, appName);
            return(_controlPanel.ScrollPressWait(appButton, expectedDestination));
        }
コード例 #2
0
        /// <summary>
        /// Stays in a holding pattern with Hpec processes the job after scan.
        /// </summary>
        public bool ProcessJobAfterScan()
        {
            _controlPanel.WaitForValue(".hp-masthead-title:last", "innerText", OmniPropertyType.Property, "Processing...", StringMatch.Contains, TimeSpan.FromSeconds(3));

            // Doing the check here just in case the popup occurs first. This will save waiting 30 seconds for the notification panel to fail.
            if (_controlPanel.CheckState(".hp-popup-modal-overlay", OmniElementState.Exists))
            {
                ProcessScanError();
            }
            RecordEvent(DeviceWorkflowMarker.ProcessingJobBegin);
            if (_notificationPanel.WaitForState(OmniElementState.VisibleCompletely))
            {
                _notificationPanel.WaitForDisplaying("Processing...");
                _notificationPanel.WaitForNotDisplaying("Processing...");
            }
            else if (_controlPanel.CheckState(".hp-popup-modal-overlay", OmniElementState.Exists))
            {
                ProcessScanError();
            }

            _controlPanel.WaitForValue(".hp-masthead-title:last", "innerText", OmniPropertyType.Property, "Result", StringMatch.Contains, TimeSpan.FromSeconds(120));
            RecordEvent(DeviceWorkflowMarker.ProcessingJobEnd);

            if (!_engine.WaitForHtmlContains("Scanned pages", TimeSpan.FromSeconds(6)))
            {
                throw new DeviceWorkflowException("Unable to determine number of pages scanned.");
            }
            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Launches the Workflow application on the device.
        /// </summary>
        public void Launch()
        {
            bool appLoaded = false;

            // The button ID uses a generated identifier which always starts with the same GUID
            string appButtonId = _controlPanel.GetIds("[id^=hpid-1c043000]", OmniIdCollectionType.Self).FirstOrDefault();

            if (appButtonId != null)
            {
                RecordEvent(DeviceWorkflowMarker.AppButtonPress, "DSS Workflow");
                appLoaded = _controlPanel.ScrollPressWait($"#{appButtonId}", "#hpid-oxpd-scroll-pane", TimeSpan.FromSeconds(10));
                RecordEvent(DeviceWorkflowMarker.AppShown);
                Pacekeeper.Pause();
            }
            else
            {
                throw new DeviceWorkflowException("DSS Workflow application button was not found on device home screen.");
            }

            if (!appLoaded)
            {
                if (_controlPanel.CheckState("#hpid-signin-app-screen", OmniElementState.Exists))
                {
                    throw new DeviceWorkflowException("Sign-in required to launch the DSS Workflow application.");
                }
                else
                {
                    throw new DeviceWorkflowException("Could not launch DSS Workflow application.");
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Waits for the specified element to be visible, enabled, and stationary.
        /// </summary>
        /// <param name="controlPanel">The control panel.</param>
        /// <param name="elementSelector">The element selector.</param>
        /// <param name="waitTime">The amount of time to wait for the element to be available.</param>
        /// <returns><c>true</c> if the element was available within the specified time, <c>false</c> otherwise.</returns>
        public static bool WaitForAvailable(this JediOmniControlPanel controlPanel, string elementSelector, TimeSpan waitTime)
        {
            bool isReady()
            {
                return(controlPanel.CheckState(elementSelector, OmniElementState.Enabled) &&
                       controlPanel.CheckState(elementSelector, OmniElementState.Useable));
            }

            return(Wait.ForTrue(isReady, waitTime));
        }
コード例 #5
0
 private void HpcrAppReady()
 {
     if (_controlPanel.CheckState(_masthead.MastheadSpinner, OmniElementState.Exists))
     {
         if (Wait.ForTrue(() => _masthead.BusyStateActive(), TimeSpan.FromSeconds(1)))
         {
             _masthead.WaitForBusyState(false, _idleTimeoutOffset);
         }
     }
 }
コード例 #6
0
        /// <summary>
        /// Launches the Copy application on the device.
        /// </summary>
        public void Launch()
        {
            _launchHelper.WorkflowLogger = WorkflowLogger;

            bool appLoaded = PressCopyButton("#hpid-copy-landing-page");

            if (appLoaded)
            {
                RecordEvent(DeviceWorkflowMarker.AppShown);
            }
            else
            {
                if (_controlPanel.CheckState("#hpid-signin-app-screen", OmniElementState.Exists))
                {
                    throw new DeviceWorkflowException("Sign-in required to launch the Copy application.");
                }
                else
                {
                    throw new DeviceWorkflowException("Could not launch Copy application.");
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Opens Contacts screen with the specified authenticator using the given authentication mode.
        /// </summary>
        /// <param name="authenticator">The authenticator.</param>
        /// <param name="authenticationMode">The authentication mode.</param>
        public void Launch(IAuthenticator authenticator, AuthenticationMode authenticationMode)
        {
            bool signInScreenLoaded = false;

            if (authenticationMode.Equals(AuthenticationMode.Lazy))
            {
                if (_controlPanel.CheckState("#hpid-settings-homescreen-button", OmniElementState.Exists))
                {
                    RecordEvent(DeviceWorkflowMarker.AppButtonPress, "Settings");
                    signInScreenLoaded = _controlPanel.ScrollPressWait("#hpid-settings-homescreen-button", "#hpid-signin-body", TimeSpan.FromSeconds(10));
                    Pacekeeper.Pause();
                }
                else
                {
                    throw new DeviceWorkflowException("Settings button was not found on device home screen.");
                }
                if (!signInScreenLoaded)
                {
                    if (_controlPanel.CheckState("#hpid-settings-homescreen-button", OmniElementState.Exists))
                    {
                        // The application launched without prompting for credentials
                        Pacekeeper.Reset();
                    }
                    else
                    {
                        throw new DeviceWorkflowException("Could not open Settings");
                    }
                }
                else
                {
                    Authenticate(authenticator, "#hpid-settings-homescreen-button");
                }
                RecordEvent(DeviceWorkflowMarker.AppShown);
            }
            else
            {
                throw new NotImplementedException("Eager authentication has not been implemented for this solution.");
            }
        }
コード例 #8
0
        private bool PressContactsHomescreenButton()
        {
            bool signInScreenLoaded = false;

            // Determine whether the Contacts Button is on the home screen
            if (_controlPanel.CheckState("#hpid-contacts-homescreen-button", OmniElementState.Exists))
            {
                RecordEvent(DeviceWorkflowMarker.AppButtonPress, "Contacts");
                try
                {
                    signInScreenLoaded = _controlPanel.ScrollPressWait("#hpid-contacts-homescreen-button", "#hpid-signin-body", TimeSpan.FromSeconds(6));
                }
                catch (Exception)
                {
                    signInScreenLoaded = false;
                }

                if (!signInScreenLoaded)
                {
                    if (!_controlPanel.CheckState("#hpid-contacts-app-screen", OmniElementState.Exists))
                    {
                        _controlPanel.ScrollPress("#hpid-contacts-homescreen-button");
                        if (!_controlPanel.ScrollPressWait("#hpid-contacts-homescreen-button", "#hpid-app-record-list", TimeSpan.FromSeconds(30)))
                        {
                            // The application launched without prompting for credentials or moving to the contacts application string
                            throw new DeviceWorkflowException("Could not launch contacts application.");
                        }
                    }
                }
                Pacekeeper.Pause();
            }
            else
            {
                throw new DeviceWorkflowException("Contacts application button was not found on device home screen.");
            }

            return(signInScreenLoaded);
        }
コード例 #9
0
        private void EnableNotification(NotifyCondition condition, string notificationRadioButton, bool includeThumbnail)
        {
            string conditionSelector = condition == NotifyCondition.OnlyIfJobFails ? "#hpid-notification-condition-selection-allerrors" : "#hpid-notification-condition-selection-always";

            _controlPanel.ScrollPressWait(conditionSelector, notificationRadioButton);
            Pacekeeper.Sync();

            if (_controlPanel.CheckState(notificationRadioButton, OmniElementState.Exists))
            {
                _controlPanel.ScrollToItem(notificationRadioButton);
                if (_controlPanel.CheckState(notificationRadioButton, OmniElementState.Useable))
                {
                    _controlPanel.ScrollPress(notificationRadioButton);
                    SetCheckBoxState("#hpid-thumbnail-checkbox", includeThumbnail);
                    Pacekeeper.Sync();
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Wait for job completed
        /// </summary>
        public override bool WaitForScanning(int scanCount)
        {
            int _count = 0;

            while (_controlPanel.CheckState("#hpid-button-Cancel", OmniElementState.Exists))
            {
                if (_count > 100)
                {
                    return(false);
                }
                _count++;
                Thread.Sleep(500);
            }
            Thread.Sleep(3000);
            PressButton(_okButtonIdScan[0]);
            return(_engine.WaitForHtmlContains(_homeButtonId[0], TimeSpan.FromSeconds(5)));
        }
コード例 #11
0
        private void UseKeyPad(int numCopies)
        {
            Thread.Sleep(1000);

            if (_controlPanel.CheckState("#hpid-keypad-key-close", OmniElementState.Exists))
            {
                _controlPanel.Type(SpecialCharacter.Backspace);
                _controlPanel.TypeOnVirtualKeyboard(numCopies.ToString());
                _controlPanel.Press("#hpid-keypad-key-close");
            }
            else
            {
                _controlPanel.Type(SpecialCharacter.RightArrow);
                _controlPanel.Type(SpecialCharacter.Backspace);
                _controlPanel.TypeOnVirtualKeyboard(numCopies.ToString());
                _controlPanel.Press("#hpid-keyboard-key-done");
            }
        }
コード例 #12
0
        /// <summary>
        /// Sets the copy count.
        /// </summary>
        /// <param name="numCopies">The number copies.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public override void SetCopyCount(int numCopies)
        {
            ProcessCopyCount();
            Thread.Sleep(1000);

            _controlPanel.Type(SpecialCharacter.Backspace);
            _controlPanel.TypeOnVirtualKeyboard(numCopies.ToString());

            // The new server is using the keyboard instead of the keypad...
            if (_controlPanel.CheckState("#hpid-keyboard-key-done", OmniElementState.Exists))
            {
                _controlPanel.Press("#hpid-keyboard-key-done");
            }
            else
            {
                _controlPanel.Press("#hpid-keypad-key-close");
            }
        }
コード例 #13
0
        /// <summary>
        /// 2017 April 19 MaxT: This code was copy/pasted from Authentication plugin per Kelly Youngman as the least offensive quick fix.  After the Authentication classes are moved to PluginSupport,
        /// this code can be removed and PluginSupport will be referenced.
        /// </summary>
        protected void UnauthenticateByTimeout()
        {
            var maxTime = DateTime.UtcNow.AddMinutes(10);

            if (Wait.ForTrue(() => _controlPanel.CheckState(".hp-homescreen-folder-view", OmniElementState.Useable), maxTime.Subtract(DateTime.UtcNow)))
            {
                // Verify
                if (DateTime.UtcNow >= maxTime ||
                    !Wait.ForTrue(() => IsUserSignedOut(), maxTime.Subtract(DateTime.UtcNow))
                    )
                {
                    throw new DeviceInvalidOperationException("Did not sign out within inactivity timeout");
                }
            }
            else
            {
                throw new DeviceInvalidOperationException("Did not return to home screen within inactivity timeout");
            }
        }
コード例 #14
0
 private void PressSignOutButton()
 {
     if (_controlPanel.CheckState(JediOmniLaunchHelper.SignInOrSignoutButton, OmniElementState.Useable))
     {
         string text = _controlPanel.GetValue(JediOmniLaunchHelper.SignInOrSignoutButton, "innerText", OmniPropertyType.Property);
         if (text.Contains("Sign Out"))
         {
             // Press the sign out button, then wait for the notification dropdown to appear and then disappear
             _controlPanel.Press(JediOmniLaunchHelper.SignInOrSignoutButton);
             _controlPanel.WaitForState(_notificationPanel, OmniElementState.VisibleCompletely, TimeSpan.FromSeconds(5));
             _controlPanel.WaitForState(JediOmniLaunchHelper.SignInOrSignoutButton, OmniElementState.VisibleCompletely, TimeSpan.FromSeconds(20));
         }
     }
     else
     {
         throw new DeviceWorkflowException("Sign out button is not usable.");
     }
 }
コード例 #15
0
        /// <summary>
        /// Executes the currently configured scan job.
        /// </summary>
        /// <param name="executionOptions">The execution options.</param>
        /// <param name="startButton">The name of the start button.</param>
        /// <returns><c>true</c> if the job finishes (regardless of its ending status), <c>false</c> otherwise.</returns>
        public bool ExecuteScanJob(ScanExecutionOptions executionOptions, string startButton)
        {
            if (executionOptions == null)
            {
                throw new ArgumentNullException(nameof(executionOptions));
            }

            // Close the options panel if it is visible (applicable to 4.3" control panels)
            CloseOptionsPanel(startButton);

            // Close the keyboard if it is visible
            if (_controlPanel.CheckState("#hpid-keyboard-key-done", OmniElementState.Useable))
            {
                _controlPanel.PressWait("#hpid-keyboard-key-done", startButton);
            }

            // Check image preview availability and make sure it is compatible with the execution options
            ValidateImagePreviewAvailability(executionOptions, startButton);

            // Determine parameters and start job
            if (UseImagePreview(executionOptions))
            {
                ExecuteImagePreviewScan(executionOptions, startButton);
            }
            else if (executionOptions.JobBuildSegments > 1)
            {
                ExecuteJobBuildScan(executionOptions, startButton);
            }
            else
            {
                // Simple single page scan - no setup, just need to press the button
                _controlPanel.WaitForAvailable(startButton);
                RecordEvent(DeviceWorkflowMarker.ScanJobBegin);
                _controlPanel.Press(startButton);
                WaitForScanToFinish();
                RecordEvent(DeviceWorkflowMarker.ScanJobEnd);
            }

            // Wait for the job to finish and report success
            return(WaitForJobFinish(executionOptions.ValidateJobExecution));
        }
コード例 #16
0
        private bool HandlePopups()
        {
            bool success = Wait.ForTrue(() =>
            {
                if (_jediOmniPopupManager.HandleButtonOk("#hpid-button-ok", "Insufficient") == true || _controlPanel.CheckState(JediOmniLaunchHelper.LazySuccessScreen, OmniElementState.Useable))
                {
                    return(true);
                }
                return(false);
            }
                                        , TimeSpan.FromSeconds(5));

            return(success);
        }
コード例 #17
0
 /// <summary>
 /// Determines whether the screen is displaying a popup.
 /// </summary>
 /// <returns><c>true</c> if there is a popup displayed; otherwise, <c>false</c>.</returns>
 public bool PopupDisplayed()
 {
     return(_controlPanel.CheckState(".hp-popup-modal-overlay,.hp-prompt", OmniElementState.Exists));
 }