/// <summary> /// Switches to snapshot mode and selects appropriate element /// </summary> /// <param name="followUp">An action to perform after tests have been run</param> private void StartElementHowToFixView(Action followUp = null) { var ecId = SelectAction.GetDefaultInstance().SelectedElementContextId; this.CurrentPage = AppPage.Test; this.CurrentView = TestView.ElementHowToFix; var tp = GetDataAction.GetProcessAndUIFrameworkOfElementContext(ecId.Value); PageTracker.TrackPage(this.CurrentPage, this.CurrentView.ToString(), tp.Item2); this.ctrlCurMode.HideControl(); this.ctrlCurMode = this.ctrlSnapMode; this.ctrlSnapMode.DataContextMode = GetDataContextModeForTest(); this.ctrlCurMode.ShowControl(); DisableElementSelector(); #pragma warning disable CA2008 // Do not create tasks without passing a TaskScheduler ctrlSnapMode.SetElement(ecId.Value).ContinueWith( t => { followUp?.Invoke(); }); #pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler }
/// <summary> /// Start fastpass mode. /// </summary> private void StartTestAutomatedChecksView() { var ec = SelectAction.GetDefaultInstance().SelectedElementContextId; if (ec != null) { DisableElementSelector(); ctrlCurMode.HideControl(); // make sure that we honor loaded data. but in this case, some of manual test should be disabled. ctrlTestMode.DataContextMode = GetDataContextModeForTest(); ctrlCurMode = ctrlTestMode; ctrlCurMode.ShowControl(); // set mode to data capturing this.CurrentPage = AppPage.Test; this.CurrentView = TestView.CapturingData; #pragma warning disable CS4014 // NOTE: We aren't awaiting this async call, so if you // touch it, consider if you need to add the await this.ctrlTestMode.SetElement(ec.Value); #pragma warning restore CS4014 var tp = GetDataAction.GetProcessAndUIFrameworkOfElementContext(ec.Value); PageTracker.TrackPage(this.CurrentPage, this.CurrentView.ToString(), tp.Item2); } else { this.AllowFurtherAction = false; MessageDialog.Show(Properties.Resources.StartElementDetailViewNoElementIsSelectedMessage); this.AllowFurtherAction = true; } }
/// <summary> /// Start snapshot mode. /// </summary> private void StartElementDetailView() { var ecId = SelectAction.GetDefaultInstance().SelectedElementContextId; if (ecId != null) { this.CurrentPage = AppPage.Test; this.CurrentView = TestView.CapturingData; DisableElementSelector(); var tp = GetDataAction.GetProcessAndUIFrameworkOfElementContext(ecId.Value); PageTracker.TrackPage(this.CurrentPage, this.CurrentView.ToString(), tp.Item2); this.ctrlCurMode.HideControl(); this.ctrlCurMode = this.ctrlSnapMode; this.ctrlSnapMode.DataContextMode = GetDataContextModeForTest(); this.ctrlCurMode.ShowControl(); #pragma warning disable CS4014 // NOTE: We aren't awaiting this async call, so if you // touch it, consider if you need to add the await ctrlSnapMode.SetElement(ecId.Value); #pragma warning restore CS4014 } else { this.AllowFurtherAction = false; MessageDialog.Show(Properties.Resources.StartElementDetailViewNoElementIsSelectedMessage); this.AllowFurtherAction = true; } }
/// <summary> /// Allow to change view value from mode control and update title. /// </summary> /// <param name="view"></param> internal void SetCurrentViewAndUpdateUI(dynamic view) { var ec = SelectAction.GetDefaultInstance().GetSelectedElementContextId(); this.CurrentView = view; if (ec != null) { var tp = GetDataAction.GetProcessAndUIFrameworkOfElementContext(ec.Value); PageTracker.TrackPage(this.CurrentPage, this.CurrentView.ToString(), tp.Item2); } UpdateTitleString(); UpdateMainCommandButtons(); }
public ResultsT Scan <ResultsT>(A11yElement element, ScanActionCallback <ResultsT> scanCallback) { if (element == null) { throw new ArgumentNullException(nameof(element)); } if (scanCallback == null) { throw new ArgumentNullException(nameof(scanCallback)); } using (var dataManager = DataManager.GetDefaultInstance()) using (var sa = SelectAction.GetDefaultInstance()) { sa.SetCandidateElement(element); if (!sa.Select()) { throw new AxeWindowsAutomationException(DisplayStrings.ErrorUnableToSetDataContext); } using (ElementContext ec2 = sa.POIElementContext) { Stopwatch stopwatch = Stopwatch.StartNew(); GetDataAction.GetProcessAndUIFrameworkOfElementContext(ec2.Id); if (!CaptureAction.SetTestModeDataContext(ec2.Id, DataContextMode.Test, TreeViewMode.Control)) { throw new AxeWindowsAutomationException(DisplayStrings.ErrorUnableToSetDataContext); } long scanDurationInMilliseconds = stopwatch.ElapsedMilliseconds; // send telemetry of scan results. var dc = GetDataAction.GetElementDataContext(ec2.Id); dc.PublishScanResults(scanDurationInMilliseconds); if (dc.ElementCounter.UpperBoundExceeded) { throw new AxeWindowsAutomationException(string.Format(CultureInfo.InvariantCulture, DisplayStrings.ErrorTooManyElementsToSetDataContext, dc.ElementCounter.UpperBound)); } return(scanCallback(ec2.Element, ec2.Id)); } // using }// using }