diff --git a/Ginger/Ginger/Actions/ActionEditPages/ActAccessibilityTestingEditPage.xaml.cs b/Ginger/Ginger/Actions/ActionEditPages/ActAccessibilityTestingEditPage.xaml.cs index 9834bc17fb..da7e649361 100644 --- a/Ginger/Ginger/Actions/ActionEditPages/ActAccessibilityTestingEditPage.xaml.cs +++ b/Ginger/Ginger/Actions/ActionEditPages/ActAccessibilityTestingEditPage.xaml.cs @@ -106,8 +106,8 @@ public ActAccessibilityTestingEditPage(ActAccessibilityTesting act) xSeverityCB.Init(mAct, nameof(mAct.SeverityList)); xLocateValueVE.BindControl(Context.GetAsContext(mAct.Context), mAct, Act.Fields.LocateValue); - xTargetRadioButton.Init(typeof(ActAccessibilityTesting.eTarget), xTargetRadioButtonPnl, mAct.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Target, ActAccessibilityTesting.eTarget.Page.ToString()), TargetRadioButton_Clicked); - xAnalyzerRadioButton.Init(typeof(ActAccessibilityTesting.eAnalyzer), xAnalyzerRadioButtonPnl, mAct.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Analyzer, ActAccessibilityTesting.eAnalyzer.ByStandard.ToString()), AnalyzerRadioButton_Clicked); + xTargetRadioButton.Init(typeof(ActAccessibilityTesting.eTarget), xTargetRadioButtonPnl, mAct.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Target, nameof(ActAccessibilityTesting.eTarget.Page)), TargetRadioButton_Clicked); + xAnalyzerRadioButton.Init(typeof(ActAccessibilityTesting.eAnalyzer), xAnalyzerRadioButtonPnl, mAct.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Analyzer, nameof(ActAccessibilityTesting.eAnalyzer.ByStandard)), AnalyzerRadioButton_Clicked); BindControlForTarget(); BindControlForAnalyzer(); SetLocateValueFrame(); @@ -115,7 +115,7 @@ public ActAccessibilityTestingEditPage(ActAccessibilityTesting act) private void BindControlForTarget() { - if ((mAct.GetInputParamValue(ActAccessibilityTesting.Fields.Target) == ActAccessibilityTesting.eTarget.Element.ToString())) + if ((mAct.GetInputParamValue(ActAccessibilityTesting.Fields.Target) == nameof(ActAccessibilityTesting.eTarget.Element))) { xLocateByAndValuePanel.Visibility = System.Windows.Visibility.Visible; } @@ -126,12 +126,12 @@ private void BindControlForTarget() } private void BindControlForAnalyzer() { - if ((mAct.GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == ActAccessibilityTesting.eAnalyzer.ByStandard.ToString())) + if ((mAct.GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == nameof(ActAccessibilityTesting.eAnalyzer.ByStandard))) { xStdStack.Visibility = System.Windows.Visibility.Visible; xSeveritylbl.Content = "Acceptable Severities :"; } - else if ((mAct.GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == ActAccessibilityTesting.eAnalyzer.BySeverity.ToString())) + else if ((mAct.GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == nameof(ActAccessibilityTesting.eAnalyzer.BySeverity))) { xStdStack.Visibility = System.Windows.Visibility.Collapsed; xSeveritylbl.Content = "Severities :"; @@ -232,13 +232,13 @@ private void SetLocateValueControls() public ObservableList GetStandardTagslist() { ObservableList StandardTagList = new ObservableList(); - StandardTagList.Add(new OperationValues() { Value = ActAccessibilityTesting.eTags.wcag2a.ToString(), DisplayName = GingerCore.General.GetEnumValueDescription(typeof(ActAccessibilityTesting.eTags), ActAccessibilityTesting.eTags.wcag2a.ToString()) }); - StandardTagList.Add(new OperationValues() { Value = ActAccessibilityTesting.eTags.wcag2aa.ToString(), DisplayName = GingerCore.General.GetEnumValueDescription(typeof(ActAccessibilityTesting.eTags), ActAccessibilityTesting.eTags.wcag2aa.ToString()) }); - StandardTagList.Add(new OperationValues() { Value = ActAccessibilityTesting.eTags.wcag21a.ToString(), DisplayName = GingerCore.General.GetEnumValueDescription(typeof(ActAccessibilityTesting.eTags), ActAccessibilityTesting.eTags.wcag21a.ToString()) }); - StandardTagList.Add(new OperationValues() { Value = ActAccessibilityTesting.eTags.wcag21aa.ToString(), DisplayName = GingerCore.General.GetEnumValueDescription(typeof(ActAccessibilityTesting.eTags), ActAccessibilityTesting.eTags.wcag21aa.ToString()) }); - StandardTagList.Add(new OperationValues() { Value = ActAccessibilityTesting.eTags.wcag22a.ToString(), DisplayName = GingerCore.General.GetEnumValueDescription(typeof(ActAccessibilityTesting.eTags), ActAccessibilityTesting.eTags.wcag22a.ToString()) }); - StandardTagList.Add(new OperationValues() { Value = ActAccessibilityTesting.eTags.wcag22aa.ToString(), DisplayName = GingerCore.General.GetEnumValueDescription(typeof(ActAccessibilityTesting.eTags), ActAccessibilityTesting.eTags.wcag22aa.ToString()) }); - StandardTagList.Add(new OperationValues() { Value = ActAccessibilityTesting.eTags.bestpractice.ToString(), DisplayName = GingerCore.General.GetEnumValueDescription(typeof(ActAccessibilityTesting.eTags), ActAccessibilityTesting.eTags.bestpractice.ToString()) }); + StandardTagList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eTags.wcag2a), DisplayName = GingerCore.General.GetEnumValueDescription(typeof(ActAccessibilityTesting.eTags), nameof(ActAccessibilityTesting.eTags.wcag2a)) }); + StandardTagList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eTags.wcag2aa), DisplayName = GingerCore.General.GetEnumValueDescription(typeof(ActAccessibilityTesting.eTags), nameof(ActAccessibilityTesting.eTags.wcag2aa)) }); + StandardTagList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eTags.wcag21a), DisplayName = GingerCore.General.GetEnumValueDescription(typeof(ActAccessibilityTesting.eTags), nameof(ActAccessibilityTesting.eTags.wcag21a)) }); + StandardTagList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eTags.wcag21aa), DisplayName = GingerCore.General.GetEnumValueDescription(typeof(ActAccessibilityTesting.eTags), nameof(ActAccessibilityTesting.eTags.wcag21aa)) }); + StandardTagList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eTags.wcag22a), DisplayName = GingerCore.General.GetEnumValueDescription(typeof(ActAccessibilityTesting.eTags), nameof(ActAccessibilityTesting.eTags.wcag22a)) }); + StandardTagList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eTags.wcag22aa), DisplayName = GingerCore.General.GetEnumValueDescription(typeof(ActAccessibilityTesting.eTags), nameof(ActAccessibilityTesting.eTags.wcag22aa)) }); + StandardTagList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eTags.bestpractice), DisplayName = GingerCore.General.GetEnumValueDescription(typeof(ActAccessibilityTesting.eTags), nameof(ActAccessibilityTesting.eTags.bestpractice)) }); return StandardTagList; } @@ -246,10 +246,10 @@ public ObservableList GetSeverityList() { ObservableList SeverityList = new ObservableList(); - SeverityList.Add(new OperationValues() { Value = ActAccessibilityTesting.eSeverity.Critical.ToString() }); - SeverityList.Add(new OperationValues() { Value = ActAccessibilityTesting.eSeverity.Serious.ToString() }); - SeverityList.Add(new OperationValues() { Value = ActAccessibilityTesting.eSeverity.Moderate.ToString() }); - SeverityList.Add(new OperationValues() { Value = ActAccessibilityTesting.eSeverity.Minor.ToString() }); + SeverityList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eSeverity.Critical) }); + SeverityList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eSeverity.Serious) }); + SeverityList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eSeverity.Moderate) }); + SeverityList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eSeverity.Minor) }); return SeverityList; } diff --git a/Ginger/Ginger/MenusLib/ConfigurationsMenu.cs b/Ginger/Ginger/MenusLib/ConfigurationsMenu.cs index 717db9db43..bea03e486b 100644 --- a/Ginger/Ginger/MenusLib/ConfigurationsMenu.cs +++ b/Ginger/Ginger/MenusLib/ConfigurationsMenu.cs @@ -92,6 +92,10 @@ private static TwoLevelMenu GetMenu() externalConfigMenu.Add(eImageType.Exchange, "Ask Lisa Configuration", GetAskLisaConfigsPage, ConsoleKey.X, "Ask Lisa Configurations", "Ask Lisa Configuration AID"); twoLevelMenu.Add(externalConfigMenu); + TopMenuItem accessiblityRulesMenu = new TopMenuItem(eImageType.Accessibility, $"{GingerCore.General.GetEnumValueDescription(typeof(eTermResKey), nameof(eTermResKey.AccessibilityRules))}", ConsoleKey.T, $"{GingerCore.General.GetEnumValueDescription(typeof(eTermResKey), nameof(eTermResKey.AccessibilityRules))}", "Name & rules of the Accessibility which been present current json"); + accessiblityRulesMenu.Add(eImageType.Application, "", GetAccessibilityRulePage, ConsoleKey.T, "", "AID"); + twoLevelMenu.Add(accessiblityRulesMenu); + return twoLevelMenu; } @@ -155,5 +159,10 @@ private static Page OthersPage() { return new Page(); } + + private static Page GetAccessibilityRulePage() + { + return (new AccessibilityRulePage()); + } } } diff --git a/Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml b/Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml new file mode 100644 index 0000000000..3d47dce4e3 --- /dev/null +++ b/Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + diff --git a/Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml.cs b/Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml.cs new file mode 100644 index 0000000000..9950bbbcce --- /dev/null +++ b/Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml.cs @@ -0,0 +1,137 @@ +using amdocs.ginger.GingerCoreNET; +using Amdocs.Ginger; +using Amdocs.Ginger.Common; +using Amdocs.Ginger.CoreNET.ActionsLib.UI.Web; +using Amdocs.Ginger.CoreNET.GeneralLib; +using Amdocs.Ginger.Repository; +using Ginger.Configurations; +using Ginger.Run; +using Ginger.SolutionGeneral; +using Ginger.UserControls; +using GingerCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Ginger.SolutionWindows +{ + /// + /// Interaction logic for AccessibilityRulePage.xaml + /// + public partial class AccessibilityRulePage : Page + { + Solution mSolution; + string AppName; + private AccessibilityConfiguration mAccessibilityConfiguration; + private static ActAccessibilityTesting actAccessibilityTesting = new ActAccessibilityTesting(); + public AccessibilityRulePage() + { + InitializeComponent(); + mSolution = WorkSpace.Instance.Solution; + string allProperties = string.Empty; + LoadGridData(); + SetAppsGrid(); + mAccessibilityConfiguration = !WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems().Any() ? new AccessibilityConfiguration() : WorkSpace.Instance.SolutionRepository.GetFirstRepositoryItem(); + mAccessibilityConfiguration.ExcludedRules = mAccessibilityConfiguration.ExcludedRules != null ? mAccessibilityConfiguration.ExcludedRules : new (); + } + + private void SetAppsGrid() + { + xAccessibilityRulesGrid.SetGridEnhancedHeader(Amdocs.Ginger.Common.Enums.eImageType.Accessibility, $"{GingerCore.General.GetEnumValueDescription(typeof(eTermResKey), nameof(eTermResKey.AccessibilityRules))}", null, null, true); + GridViewDef view = new GridViewDef(GridViewDef.DefaultViewName); + view.GridColsView = new ObservableList(); + view.GridColsView.Add(new GridColView() + { + Field = nameof(AccessibilityRuleData.Active), + WidthWeight = 2, + StyleType = GridColView.eGridColStyleType.Template, + CellTemplate = (DataTemplate)FindResource("CheckBoxTemplate"), + AllowSorting = true + }); + view.GridColsView.Add(new GridColView() + { + Field = nameof(AccessibilityRuleData.RuleID), + Header = "RuleID", + ReadOnly = true, + WidthWeight = 15, + AllowSorting = true + }); + view.GridColsView.Add(new GridColView() + { + Field = nameof(AccessibilityRuleData.Description), + Header = "Description", + WidthWeight = 40, + ReadOnly = true + }); + view.GridColsView.Add(new GridColView() + { + Field = nameof(AccessibilityRuleData.Impact), + Header = "Severity", + WidthWeight = 5, + ReadOnly = true, + AllowSorting = true + }); + view.GridColsView.Add(new GridColView() + { + Field = nameof(AccessibilityRuleData.Tags), + WidthWeight = 30, + ReadOnly = true + }); + + xAccessibilityRulesGrid.AddLabel("Note: Ginger will only analyze the active accessibility testing rules; inactive rules will not be considered."); + + xAccessibilityRulesGrid.SetAllColumnsDefaultView(view); + xAccessibilityRulesGrid.InitViewItems(); + } + + private void LoadGridData() + { + List sortedList = actAccessibilityTesting.RulesItemsdata.OrderByDescending(data => !data.Active).ToList(); + ObservableList accessibilityRuleDatas = [.. sortedList]; + xAccessibilityRulesGrid.DataSourceList = accessibilityRuleDatas; + } + + private void CheckBox_Click(object sender, RoutedEventArgs e) + { + CheckBox checkBox = sender as CheckBox; + if (checkBox != null && checkBox.DataContext is AccessibilityRuleData data) + { + // Do something with data, for example: + data.Active = checkBox.IsChecked ?? false; + mAccessibilityConfiguration.StartDirtyTracking(); + if (!data.Active) + { + if(!mAccessibilityConfiguration.ExcludedRules.Any()) + { + GingerCoreNET.GeneralLib.General.CreateDefaultAccessiblityconfiguration(); + mAccessibilityConfiguration = WorkSpace.Instance.SolutionRepository.GetFirstRepositoryItem(); + mAccessibilityConfiguration.ExcludedRules = mAccessibilityConfiguration.ExcludedRules != null ? mAccessibilityConfiguration.ExcludedRules : new(); + } + + if (!mAccessibilityConfiguration.ExcludedRules.Any(x => x.Equals(data.RuleID))) + { + mAccessibilityConfiguration.ExcludedRules.Add(data); + } + } + else + { + if (mAccessibilityConfiguration.ExcludedRules.Any(x => x.Equals(data.RuleID))) + { + mAccessibilityConfiguration.ExcludedRules.Remove(data); + } + } + } + } + } +} diff --git a/Ginger/Ginger/SolutionWindows/AddSolutionPage.xaml.cs b/Ginger/Ginger/SolutionWindows/AddSolutionPage.xaml.cs index 28769f22c3..4305a2a632 100644 --- a/Ginger/Ginger/SolutionWindows/AddSolutionPage.xaml.cs +++ b/Ginger/Ginger/SolutionWindows/AddSolutionPage.xaml.cs @@ -134,6 +134,7 @@ private void OKButton_Click(object sender, RoutedEventArgs e) GingerCoreNET.GeneralLib.General.CreateDefaultEnvironment(); WorkSpace.Instance.SolutionRepository.AddRepositoryItem(WorkSpace.Instance.GetNewBusinessFlow("Flow 1", true)); mSolution.SolutionOperations.SetReportsConfigurations(); + GingerCoreNET.GeneralLib.General.CreateDefaultAccessiblityconfiguration(); //Save again to keep all defualt configurations setup mSolution.SolutionOperations.SaveSolution(false); diff --git a/Ginger/Ginger/UserControlsLib/ImageMakerLib/ImageMakerControl.xaml.cs b/Ginger/Ginger/UserControlsLib/ImageMakerLib/ImageMakerControl.xaml.cs index c82bee3d07..6811cb0271 100644 --- a/Ginger/Ginger/UserControlsLib/ImageMakerLib/ImageMakerControl.xaml.cs +++ b/Ginger/Ginger/UserControlsLib/ImageMakerLib/ImageMakerControl.xaml.cs @@ -286,6 +286,10 @@ private void SetImage() case eImageType.Building: SetAsFontAwesomeIcon(EFontAwesomeIcon.Solid_Building); break; + + case eImageType.Accessibility: + SetAsFontAwesomeIcon(EFontAwesomeIcon.Solid_UniversalAccess); + break; #endregion diff --git a/Ginger/Ginger/UserControlsLib/ucGridView/ucGrid.xaml b/Ginger/Ginger/UserControlsLib/ucGridView/ucGrid.xaml index b78d0d572b..5c38dfc17d 100644 --- a/Ginger/Ginger/UserControlsLib/ucGridView/ucGrid.xaml +++ b/Ginger/Ginger/UserControlsLib/ucGridView/ucGrid.xaml @@ -19,7 +19,7 @@ - diff --git a/Ginger/GingerCoreCommon/Dictionaries/GingerDicser.cs b/Ginger/GingerCoreCommon/Dictionaries/GingerDicser.cs index 934213bd16..03e67104db 100644 --- a/Ginger/GingerCoreCommon/Dictionaries/GingerDicser.cs +++ b/Ginger/GingerCoreCommon/Dictionaries/GingerDicser.cs @@ -32,6 +32,10 @@ public enum eTermResKey Variable, Variables, RunSet, RunSets, TargetApplication, + + [EnumValueDescription("Accessibility Rules")] + AccessibilityRules, + Parameter } diff --git a/Ginger/GingerCoreCommon/EnumsLib/eImageType.cs b/Ginger/GingerCoreCommon/EnumsLib/eImageType.cs index 4243a5849b..44478e9b54 100644 --- a/Ginger/GingerCoreCommon/EnumsLib/eImageType.cs +++ b/Ginger/GingerCoreCommon/EnumsLib/eImageType.cs @@ -354,6 +354,7 @@ public enum eImageType PlusSquare, DataTable, Robot, + Accessibility, AnglesArrowLeft, AnglesArrowRight, diff --git a/Ginger/GingerCoreCommon/External/Configurations/AccessibilityConfiguration.cs b/Ginger/GingerCoreCommon/External/Configurations/AccessibilityConfiguration.cs index fb647b50de..33ac90fb56 100644 --- a/Ginger/GingerCoreCommon/External/Configurations/AccessibilityConfiguration.cs +++ b/Ginger/GingerCoreCommon/External/Configurations/AccessibilityConfiguration.cs @@ -1,4 +1,4 @@ -#region License +#region License /* Copyright © 2014-2024 European Support Limited @@ -18,6 +18,7 @@ limitations under the License. using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -29,231 +30,42 @@ namespace Ginger.Configurations { public class AccessibilityConfiguration : RepositoryItemBase { - private string mStandard; + private string mName; [IsSerializedForLocalRepository] - public string Standard - { - get - { - return mStandard; - } - set - { - if (mStandard != value) - { - mStandard = value; - OnPropertyChanged(nameof(Standard)); - } - } - } - - private ObservableList mDefaultRuleList; - - [IsSerializedForLocalRepository] - public ObservableList DefaultRuleList - { - get - { - return mDefaultRuleList; - } - set - { - if (value != mDefaultRuleList) - { - mDefaultRuleList = value; - OnPropertyChanged(nameof(DefaultRuleList)); - } - } - } - - - private string mSeverity; - [IsSerializedForLocalRepository] - public string Severity - { - get - { - return mSeverity; - } - set - { - if (mSeverity != value) - { - mSeverity = value; - OnPropertyChanged(nameof(Severity)); - } - } - } - - private Dictionary _items = new Dictionary(); - - public Dictionary Items - { - get - { - return _items; - } - set - { - _items = value; + public string Name { get { return mName; } set { if (mName != value) { mName = value; OnPropertyChanged(nameof(Name)); } } } + - } - } - private ObservableList mOperationValueList; + ObservableList mExcludedRules; [IsSerializedForLocalRepository] - public ObservableList OperationValueList + public ObservableList ExcludedRules { get { - return mOperationValueList; + return mExcludedRules; } set { - if (value != mOperationValueList) + if (mExcludedRules != value) { - mOperationValueList = value; - OnPropertyChanged(nameof(OperationValueList)); + mExcludedRules = value; + OnPropertyChanged(nameof(ExcludedRules)); } } } - private Dictionary _SeverityItems = new Dictionary(); - - public Dictionary SeverityItems - { - get - { - return _SeverityItems; - } - set - { - _SeverityItems = value; - - } - } - - private ObservableList mSeverityOperationValueList; - [IsSerializedForLocalRepository] - public ObservableList SeverityOperationValueList + public override string ItemName { get { - return mSeverityOperationValueList; + return this.Name; } set { - if (value != mSeverityOperationValueList) - { - mSeverityOperationValueList = value; - OnPropertyChanged(nameof(SeverityOperationValueList)); - } + this.Name = value; } } - - - public override string ItemName { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); } - - public ObservableList GetAccessibilityRules() - { - ObservableList accessibilityRules = new ObservableList(); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "area-alt", Description = "Ensures elements of image maps have alternate text", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "c487ae"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-allowed-attr", Description = "Ensures an element's role supports its ARIA attributes", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "5c01ea"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-braille-equivalent", Description = "Ensure aria-braillelabel and aria-brailleroledescription have a non-braille equivalent", Impact = "Serious", Tags = "wcag2a" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-command-name", Description = "Ensures every ARIA button, link and menuitem has an accessible name", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "97a4e1"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-conditional-attr", Description = "Ensures ARIA attributes are used as described in the specification of the element's role", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "5c01ea"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-deprecated-role", Description = "Ensures elements do not use deprecated roles", Impact = "Minor", Tags = "wcag2a" ,ACTRules = "674b10"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-hidden-body", Description = "Ensures aria-hidden = true is not present on the document body.", Impact = "Critical", Tags = "wcag2a" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-hidden-focus", Description = "Ensures aria-hidden elements are not focusable nor contain focusable elements", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "6cfa84"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-input-field-name", Description = "Ensures every ARIA input field has an accessible name", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "e086e5"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-meter-name", Description = "Ensures every ARIA meter node has an accessible name", Impact = "Serious", Tags = "wcag2a" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-progressbar-name", Description = "Ensures every ARIA progressbar node has an accessible name", Impact = "Serious", Tags = "wcag2a" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-prohibited-attr", Description = "Ensures ARIA attributes are not prohibited for an element's role", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "5c01ea"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-required-attr", Description = "Ensures elements with ARIA roles have all required ARIA attributes", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "4e8ab6"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-required-children", Description = "Ensures elements with an ARIA role that require child roles contain them", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "bc4a75, ff89c9"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-required-parent", Description = "Ensures elements with an ARIA role that require parent roles are contained by them", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "ff89c9"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-roles", Description = "Ensures all elements with a role attribute use a valid value", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "674b10"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-toggle-field-name", Description = "Ensures every ARIA toggle field has an accessible name", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "e086e5"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-tooltip-name", Description = "Ensures every ARIA tooltip node has an accessible name", Impact = "Serious", Tags = "wcag2a" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-valid-attr-value", Description = "Ensures all ARIA attributes have valid values", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "6a7281"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-valid-attr", Description = "Ensures attributes that begin with aria- are valid ARIA attributes", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "5f99a7"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "blink", Description = "Ensures elements are not used", Impact = "Serious", Tags = "wcag2a" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "button-name", Description = "Ensures buttons have discernible text", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "97a4e1, m6b1q3"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "bypass", Description = "Ensures each page has at least one mechanism for a user to bypass navigation and jump straight to the content", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "cf77f2, 047fe0, b40fd1, 3e12e1, ye5d6e"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "color-contrast", Description = "Ensures the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds", Impact = "Serious", Tags = "wcag2aa" ,ACTRules = "afw4f7, 09o5cg"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "definition-list", Description = "Ensures
elements are structured correctly", Impact = "Serious", Tags = "wcag2a" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "dlitem", Description = "Ensures
and
elements are contained by a
", Impact = "Serious", Tags = "wcag2a" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "document-title", Description = "Ensures each HTML document contains a non-empty element", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "2779a5"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "duplicate-id-aria", Description = "Ensures every id attribute value used in ARIA and in labels is unique", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "3ea0c8"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "form-field-multiple-labels", Description = "Ensures form field does not have multiple label elements", Impact = "Moderate", Tags = "wcag2a" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "frame-focusable-content", Description = "Ensures <frame> and <iframe> elements with focusable content do not have tabindex=-1", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "akn7bn"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "frame-title-unique", Description = "Ensures <iframe> and <frame> elements contain a unique title attribute", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "4b1c6c"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "frame-title", Description = "Ensures <iframe> and <frame> elements have an accessible name", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "cae760"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "html-has-lang", Description = "Ensures every HTML document has a lang attribute", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "b5c3f8"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "html-lang-valid", Description = "Ensures the lang attribute of the <html> element has a valid value", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "bf051a"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "html-xml-lang-mismatch", Description = "Ensure that HTML elements with both valid lang and xml:lang attributes agree on the base language of the page", Impact = "Moderate", Tags = "wcag2a" ,ACTRules = "5b7ae0"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "image-alt", Description = "Ensures <img> elements have alternate text or a role of none or presentation", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "23a2a8"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "input-button-name", Description = "Ensures input buttons have discernible text", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "97a4e1"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "input-image-alt", Description = "Ensures < input type = image > elements have alternate text", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "59796f"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "label", Description = "Ensures every form element has a label", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "e086e5"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "link-in-text-block", Description = "Ensure links are distinguished from surrounding text in a way that does not rely on color", Impact = "Serious", Tags = "wcag2a" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "link-name", Description = "Ensures links have discernible text", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "c487ae"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "list", Description = "Ensures that lists are structured correctly", Impact = "Serious", Tags = "wcag2a" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "listitem", Description = "Ensures <li> elements are used semantically", Impact = "Serious", Tags = "wcag2a" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "marquee", Description = "Ensures <marquee> elements are not used", Impact = "Serious", Tags = "wcag2a" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "meta-refresh", Description = "Ensures < meta http - equiv = refresh > is not used for delayed refresh", Impact = "Critical", Tags = "wcag2a", ACTRules = "bc659a, bisz58"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "meta-viewport", Description = "Ensures < meta name = viewport > does not disable text scaling and zooming", Impact = "Critical", Tags = "wcag2aa" ,ACTRules = "b4f0c3"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "nested-interactive", Description = "Ensures interactive controls are not nested as they are not always announced by screen readers or can cause focus problems for assistive technologies", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "307n5z"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "no-autoplay-audio", Description = "Ensures <video> or <audio> elements do not autoplay audio for more than 3 seconds without a control mechanism to stop or mute the audio", Impact = "Moderate", Tags = "wcag2a" ,ACTRules = "80f0bf"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "object-alt", Description = "Ensures <object> elements have alternate text", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "8fc3b6"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "role-img-alt", Description = "Ensures[role = img] elements have alternate text", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "23a2a8"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "scrollable-region-focusable", Description = "Ensure elements that have scrollable content are accessible by keyboard", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "0ssw9k"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "select-name", Description = "Ensures select element has an accessible name", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "e086e5"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "server-side-image-map", Description = "Ensures that server-side image maps are not used", Impact = "Minor", Tags = "wcag2a" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "svg-img-alt", Description = "Ensures <svg> elements with an img, graphics-document or graphics-symbol role have an accessible text", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "7d6734"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "td-headers-attr", Description = "Ensure that each cell in a table that uses the headers attribute refers only to other cells in that table", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "a25f45"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "th-has-data-cells", Description = "Ensure that <th> elements and elements with role=columnheader/rowheader have data cells they describe", Impact = "Serious", Tags = "wcag2a" ,ACTRules = "d0f69e"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "valid-lang", Description = "Ensures lang attributes have valid values", Impact = "Serious", Tags = "wcag2aa" ,ACTRules = "de46e4"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "video-caption", Description = "Ensures <video> elements have captions", Impact = "Critical", Tags = "wcag2a" ,ACTRules = "eac66b"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "autocomplete-valid", Description = "Ensure the autocomplete attribute is correct and suitable for the form field", Impact = "Serious", Tags = "wcag21aa" ,ACTRules = "73f2c2"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "avoid-inline-spacing", Description = "Ensure that text spacing set through style attributes can be adjusted with custom stylesheets", Impact = "Serious", Tags = "wcag21aa" ,ACTRules = "24afc2, 9e45ec, 78fd32"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "target-size", Description = "Ensure touch target have sufficient size and space", Impact = "Serious", Tags = "wcag22aa" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "accesskeys", Description = "Ensures every accesskey attribute value is unique", Impact = "Serious", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-allowed-role", Description = "Ensures role attribute has an appropriate value for the element", Impact = "Minor", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-dialog-name", Description = "Ensures every ARIA dialog and alertdialog node has an accessible name", Impact = "Serious", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-text", Description = "Ensures role = text is used on elements with no focusable descendants", Impact = "Serious", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "aria-treeitem-name", Description = "Ensures every ARIA treeitem node has an accessible name", Impact = "Serious", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "empty-heading", Description = "Ensures headings have discernible text", Impact = "Minor", Tags = "bestpractice" ,ACTRules = "ffd0e9"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "empty-table-header", Description = "Ensures table headers have discernible text", Impact = "Minor", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "frame-tested", Description = "Ensures <iframe> and <frame> elements contain the axe-core script", Impact = "Critical", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "heading-order", Description = "Ensures the order of headings is semantically correct", Impact = "Moderate", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "image-redundant-alt", Description = "Ensure image alternative is not repeated as text", Impact = "Minor", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "label-title-only", Description = "Ensures that every form element has a visible label and is not solely labeled using hidden labels, or the title or aria-describedby attributes", Impact = "Serious", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "landmark-banner-is-top-level", Description = "Ensures the banner landmark is at top level", Impact = "Moderate", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "landmark-complementary-is-top-level", Description = "Ensures the complementary landmark or aside is at top level", Impact = "Moderate", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "landmark-contentinfo-is-top-level", Description = "Ensures the contentinfo landmark is at top level", Impact = "Moderate", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "landmark-main-is-top-level", Description = "Ensures the main landmark is at top level", Impact = "Moderate", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "landmark-no-duplicate-banner", Description = "Ensures the document has at most one banner landmark", Impact = "Moderate", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "landmark-no-duplicate-contentinfo", Description = "Ensures the document has at most one contentinfo landmark", Impact = "Moderate", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "landmark-no-duplicate-main", Description = "Ensures the document has at most one main landmark", Impact = "Moderate", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "landmark-one-main", Description = "Ensures the document has a main landmark", Impact = "Moderate", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "landmark-unique", Description = "Landmarks should have a unique role or role/label/title (i.e. accessible name) combination", Impact = "Moderate", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "meta-viewport-large", Description = "Ensures < meta name = viewport > can scale a significant amount", Impact = "Minor", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "page-has-heading-one", Description = "Ensure that the page, or at least one of its frames contains a level-one heading", Impact = "Moderate", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "presentation-role-conflict", Description = "Elements marked as presentational should not have global ARIA or tabindex to ensure all screen readers ignore them", Impact = "Minor", Tags = "bestpractice" ,ACTRules = "46ca7f"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "region", Description = "Ensures all page content is contained by landmarks", Impact = "Moderate", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "scope-attr-valid", Description = "Ensures the scope attribute is used correctly on tables", Impact = "Moderate", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "skip-link", Description = "Ensure all skip links have a focusable target", Impact = "Moderate", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "tabindex", Description = "Ensures tabindex attribute values are not greater than 0", Impact = "Serious", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "table-duplicate-name", Description = "Ensure the <caption> element does not contain the same text as the summary attribute", Impact = "Minor", Tags = "bestpractice" ,ACTRules = ""}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "color-contrast-enhanced", Description = "Ensures the contrast between foreground and background colors meets WCAG 2 AAA enhanced contrast ratio thresholds", Impact = "Serious", Tags = "wcag2aaa" ,ACTRules = "09o5cg"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "identical-links-same-purpose", Description = "Ensure that links with the same accessible name serve a similar purpose", Impact = "Minor", Tags = "wcag2aaa" ,ACTRules = "b20e66"}); - accessibilityRules.Add( new AccessibilityRuleData { Active = false, RuleID = "meta-refresh-no-exceptions", Description = "Ensures < meta http - equiv = refresh > is not used for delayed refresh", Impact = "Minor", Tags = "wcag2aaa", ACTRules = "bisz58"}); - return accessibilityRules; - } - - - + public override string GetNameForFileName() { return Name; } } } diff --git a/Ginger/GingerCoreCommon/External/Configurations/AccessibilityRuleData.cs b/Ginger/GingerCoreCommon/External/Configurations/AccessibilityRuleData.cs index 7124dd375b..8ccc775ec5 100644 --- a/Ginger/GingerCoreCommon/External/Configurations/AccessibilityRuleData.cs +++ b/Ginger/GingerCoreCommon/External/Configurations/AccessibilityRuleData.cs @@ -1,4 +1,4 @@ -#region License +#region License /* Copyright © 2014-2024 European Support Limited @@ -22,7 +22,11 @@ limitations under the License. using System.Linq; using System.Text; using System.Threading.Tasks; +using Amdocs.Ginger.Common; using Amdocs.Ginger.Repository; +using Ginger.Run; +using GingerCore; +using Newtonsoft.Json; namespace Ginger.Configurations { @@ -35,7 +39,6 @@ public class AccessibilityRuleData : RepositoryItemBase, INotifyPropertyChanged /// <summary> /// Gets or sets the Active associated with the accessibility rule. /// </summary> - [IsSerializedForLocalRepository] public bool Active { get { return mActive; } set { if (mActive != value) { mActive = value; OnPropertyChanged(nameof(Active)); } } } private string mRuleID; @@ -49,7 +52,7 @@ public class AccessibilityRuleData : RepositoryItemBase, INotifyPropertyChanged /// <summary> /// Gets or sets the tags associated with the accessibility rule. /// </summary> - [IsSerializedForLocalRepository] + public string Tags { get { return mTags; } set { if (mTags != value) { mTags = value; OnPropertyChanged(nameof(Tags)); } } } private string mImpact; @@ -62,10 +65,33 @@ public class AccessibilityRuleData : RepositoryItemBase, INotifyPropertyChanged public string ACTRules { get { return mACTRules; } set { if (mACTRules != value) { mACTRules = value; OnPropertyChanged(nameof(ACTRules)); } } } public override string ItemName { get; set; } + public ObservableList<AccessibilityRuleData> GetAccessibilityRules(string AccessbiltyString) + { + Root data = new(); + data.accessibilityRules = []; + try + { + data = JsonConvert.DeserializeObject<Root>(AccessbiltyString); + } + catch (Exception ex) + { + Reporter.ToLog(eLogLevel.ERROR, "Failed to deserialize accessibility rules.", ex); + } + + return data.accessibilityRules; + } + public void OnPropertyChanged(string name) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } +} + + public class Root + { + public ObservableList<AccessibilityRuleData> accessibilityRules { get; set; } } + + } diff --git a/Ginger/GingerCoreCommon/Repository/GingerSolutionRepository.cs b/Ginger/GingerCoreCommon/Repository/GingerSolutionRepository.cs index 7faac129fb..8f92ae0ee3 100644 --- a/Ginger/GingerCoreCommon/Repository/GingerSolutionRepository.cs +++ b/Ginger/GingerCoreCommon/Repository/GingerSolutionRepository.cs @@ -1,4 +1,4 @@ -#region License +#region License /* Copyright © 2014-2024 European Support Limited @@ -19,6 +19,7 @@ limitations under the License. using System.IO; using Amdocs.Ginger.Common.Run; using Amdocs.Ginger.Repository; +using Ginger.Configurations; using Ginger.Reports; using Ginger.Run; using GingerCore; @@ -66,6 +67,8 @@ public static SolutionRepository CreateGingerSolutionRepository() SR.AddItemInfo<RemoteServiceGrid>("*.Ginger.RemoteServiceGrid.xml", SolutionRepository.cSolutionRootFolderSign + "RemoteServiceGrid", true, "RemoteServiceGrid", PropertyNameForFileName: nameof(RemoteServiceGrid.Name)); + SR.AddItemInfo<AccessibilityConfiguration>("*.Ginger.Configuration.xml", SolutionRepository.cSolutionRootFolderSign + "Configurations", true, "AccessibilityConfiguration", PropertyNameForFileName: nameof(AccessibilityConfiguration.Name)); + return SR; } } diff --git a/Ginger/GingerCoreCommon/WorkSpaceLib/Solution.cs b/Ginger/GingerCoreCommon/WorkSpaceLib/Solution.cs index 4f8e8ddeb9..9dbd9c5482 100644 --- a/Ginger/GingerCoreCommon/WorkSpaceLib/Solution.cs +++ b/Ginger/GingerCoreCommon/WorkSpaceLib/Solution.cs @@ -78,6 +78,7 @@ public string Name [IsSerializedForLocalRepository] public ObservableList<RepositoryItemTag> Tags; + private string mAccount; /// <summary> diff --git a/Ginger/GingerCoreNET/ActionsLib/UI/Web/ActAccessibilityTesting.cs b/Ginger/GingerCoreNET/ActionsLib/UI/Web/ActAccessibilityTesting.cs index c1fcf65ae2..4aa0d09510 100644 --- a/Ginger/GingerCoreNET/ActionsLib/UI/Web/ActAccessibilityTesting.cs +++ b/Ginger/GingerCoreNET/ActionsLib/UI/Web/ActAccessibilityTesting.cs @@ -18,6 +18,7 @@ limitations under the License. using amdocs.ginger.GingerCoreNET; using Amdocs.Ginger.Common; +using Amdocs.Ginger.Common.Enums; using Amdocs.Ginger.Common.GeneralLib; using Amdocs.Ginger.Common.InterfacesLib; using Amdocs.Ginger.Common.UIElement; @@ -32,6 +33,7 @@ limitations under the License. using GingerCore.Platforms; using GingerCoreNET.SolutionRepositoryLib.RepositoryObjectsLib.PlatformsLib; using HtmlAgilityPack; +using Microsoft.VisualStudio.Services.Common; using Newtonsoft.Json; using OpenQA.Selenium; using System; @@ -303,18 +305,48 @@ public ObservableList<AccessibilityRuleData> RulesItemsdata public ObservableList<AccessibilityRuleData> GetRuleList() { - AccessibilityConfiguration accessibilityConfiguration = new(); - ObservableList<AccessibilityRuleData> ruleDatalist = []; + AccessibilityRuleData AccessibilityRuleDataObjet = new AccessibilityRuleData(); + AccessibilityConfiguration mAccessibilityConfiguration; + if (WorkSpace.Instance.SolutionRepository != null) + { + if(!WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<AccessibilityConfiguration>().Any()) + { + mAccessibilityConfiguration = new(); + } + else + { + mAccessibilityConfiguration = WorkSpace.Instance.SolutionRepository.GetFirstRepositoryItem<AccessibilityConfiguration>(); + } + } + else + { + mAccessibilityConfiguration = new (); + } + mAccessibilityConfiguration.ExcludedRules = mAccessibilityConfiguration.ExcludedRules != null ? mAccessibilityConfiguration.ExcludedRules : new(); + ObservableList<AccessibilityRuleData> ruleDatalist; try { - ruleDatalist = accessibilityConfiguration.GetAccessibilityRules(); + string AccessbiltyString = GetAccessiblityrules(); + ruleDatalist = AccessibilityRuleDataObjet.GetAccessibilityRules(AccessbiltyString); + foreach (AccessibilityRuleData ruleData in ruleDatalist) + { + if (mAccessibilityConfiguration.ExcludedRules != null && mAccessibilityConfiguration.ExcludedRules.Select(x=>x.RuleID).Contains(ruleData.RuleID)) + { + ruleData.Active = false; + } + else + { + ruleData.Active = true; + } + } + return ruleDatalist; } catch (Exception ex) { Error = "Error: during accessibility testing:" + ex.Message; - Reporter.ToLog(eLogLevel.ERROR, "Error: during accessibility testing", ex); + Reporter.ToLog(eLogLevel.ERROR, $"Error: during accessibility testing in GetRuleList. Configuration: {mAccessibilityConfiguration?.Name}", ex); } - return ruleDatalist; + return []; } private Dictionary<string, object> _items; @@ -356,6 +388,21 @@ public enum ReportTypes All = 15 } + public override eImageType Image { get { return eImageType.Accessibility; } } + + private static string GetAccessiblityrules() + { + try + { + return EmbeddedResourceProvider.ReadEmbeddedFile("AccessiblityRules.json"); + } + catch (Exception ex) + { + Reporter.ToLog(eLogLevel.ERROR, "Error reading accessibility rules from embedded file", ex); + return string.Empty; + } + } + public void CreateAxeHtmlReport(ISearchContext context, AxeResult results, string destination, ReportTypes requestedResults) { // Get the unwrapped element if we are using a wrapped element @@ -733,7 +780,7 @@ public void AnalyzerAccessibility(IWebDriver Driver,IWebElement element) string path = String.Empty; - if (WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder != null) + if (WorkSpace.Instance.Solution != null && WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder != null) { string folderPath = Path.Combine(WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder, @"AccessibilityReport"); if (!Directory.Exists(folderPath)) @@ -743,12 +790,10 @@ public void AnalyzerAccessibility(IWebDriver Driver,IWebElement element) string DatetimeFormate = DateTime.Now.ToString("ddMMyyyy_HHmmssfff"); string reportname = $"{ItemName}_AccessibilityReport_{DatetimeFormate}.html"; path = $"{folderPath}{Path.DirectorySeparatorChar}{reportname}"; - Act.AddArtifactToAction(Path.GetFileName(path), this, path); + Act.AddArtifactToAction(Path.GetFileName(path), this, path); + CreateAxeHtmlReport(Driver, axeResult, path, ActAccessibilityTesting.ReportTypes.All); + AddOrUpdateReturnParamActual(ParamName: "Accessibility report", ActualValue: path); } - - CreateAxeHtmlReport(Driver, axeResult, path, ActAccessibilityTesting.ReportTypes.All); - AddOrUpdateReturnParamActual(ParamName: "Accessibility report", ActualValue: path); - SetAxeResultToAction(axeResult); } catch (Exception ex) @@ -761,6 +806,7 @@ public void AnalyzerAccessibility(IWebDriver Driver,IWebElement element) public AxeBuilder CreateAxeBuilder(IWebDriver Driver) { + ObservableList<AccessibilityRuleData> RuleData = RulesItemsdata; AxeBuilder axeBuilder = null; List<string> sevritylist = null; axeBuilder = new AxeBuilder(Driver) @@ -769,15 +815,16 @@ public AxeBuilder CreateAxeBuilder(IWebDriver Driver) XPath = true }); - - if (GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == ActAccessibilityTesting.eAnalyzer.ByStandard.ToString()) + //Active field is for configuration page rules which are Active needs to Exclude in Analysis + string[] ExcludeRules = RuleData.Where(x => !x.Active).Select(i => i.RuleID.ToString()).ToArray(); + if (GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == nameof(ActAccessibilityTesting.eAnalyzer.ByStandard)) { if (StandardList != null && StandardList.Any()) { string[] Tag_array = StandardList.Select(i => i.Value.ToString()).ToArray(); - for(int i=0;i<Tag_array.Length;i++) + for (int i = 0; i < Tag_array.Length; i++) { - if (Tag_array[i].Equals("bestpractice",StringComparison.OrdinalIgnoreCase)) + if (Tag_array[i].Equals("bestpractice", StringComparison.OrdinalIgnoreCase)) { Tag_array[i] = "best-practice"; } @@ -790,61 +837,81 @@ public AxeBuilder CreateAxeBuilder(IWebDriver Driver) Error = "Standard list is empty or not set."; return axeBuilder; } + if (SeverityList != null && SeverityList.Any()) { sevritylist = SeverityList.Select(x => x.Value.ToLower()).ToList(); - string[] ExcludeRules = RulesItemsdata.Where(x => sevritylist.Contains(x.Impact.ToLower())).Select(i => i.RuleID.ToString()).ToArray(); - if (ExcludeRules != null && ExcludeRules.Any()) - { - axeBuilder.DisableRules(ExcludeRules); - } + + string[] SeverityExcludeRules = RuleData.Where(x => !ExcludeRules.Contains(x.RuleID) && sevritylist.Contains(x.Impact.ToLower())).Select(i => i.RuleID.ToString()).ToArray(); + ExcludeRules = ExcludeRules.Concat(SeverityExcludeRules).ToArray(); + } + + if (ExcludeRules != null && ExcludeRules.Any()) + { + axeBuilder.DisableRules(ExcludeRules); } - } - else if (GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == ActAccessibilityTesting.eAnalyzer.BySeverity.ToString()) + else if (GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == nameof(ActAccessibilityTesting.eAnalyzer.BySeverity)) { if (SeverityList != null && SeverityList.Any()) { sevritylist = SeverityList.Select(x => x.Value.ToLower()).ToList(); - string[] IncludeRules = RulesItemsdata.Where(x => sevritylist.Contains(x.Impact.ToLower())).Select(i => i.RuleID.ToString()).ToArray(); - if (IncludeRules != null && IncludeRules.Any()) + string[] SevarityIncludeRules = RuleData.Where(x => !ExcludeRules.Contains(x.RuleID) && sevritylist.Contains(x.Impact.ToLower())).Select(i => i.RuleID.ToString()).ToArray(); + if (SevarityIncludeRules != null && SevarityIncludeRules.Any()) { - axeBuilder.WithRules(IncludeRules); + axeBuilder.WithRules(SevarityIncludeRules); } } - else if(SeverityList == null || !SeverityList.Any()) + else if (SeverityList == null || !SeverityList.Any()) { Status = eRunStatus.Failed; Error = "Severity list is empty or not set."; return axeBuilder; } + + } return axeBuilder; } - public void SetAxeResultToAction(AxeResult axeResult) { bool hasAnyViolations = axeResult.Violations.Any(); bool ActionResult = true; IEnumerable<string> AcceptableSeverity = Enumerable.Empty<string>().ToList(); IEnumerable<string> Violationseverity = Enumerable.Empty<string>().ToList(); - if (GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == ActAccessibilityTesting.eAnalyzer.ByStandard.ToString() && SeverityList != null && SeverityList.Any()) + if (GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == nameof(ActAccessibilityTesting.eAnalyzer.ByStandard)) { - AcceptableSeverity = SeverityList.Select(x => x.Value.ToLower()).ToList(); Violationseverity = axeResult.Violations.Any() ? axeResult.Violations.Select(x => x.Impact.ToLower()) : Enumerable.Empty<string>().ToList(); - ActionResult = Violationseverity.Intersect(AcceptableSeverity).Any(); + if (SeverityList != null && SeverityList.Any()) + { + AcceptableSeverity = SeverityList.Select(x => x.Value.ToLower()).ToList(); + ActionResult = Violationseverity.Intersect(AcceptableSeverity).Any(); + } + else + { + ActionResult = Violationseverity.Any(); + } } - else if (GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == ActAccessibilityTesting.eAnalyzer.BySeverity.ToString() && SeverityList != null && SeverityList.Any()) + else if (GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == nameof(ActAccessibilityTesting.eAnalyzer.BySeverity)) { - List<string> sevritylist = SeverityList.Select(x => x.Value.ToLower()).ToList(); Violationseverity = axeResult.Violations.Any() ? axeResult.Violations.Select(x => x.Impact.ToLower()) : Enumerable.Empty<string>().ToList(); - foreach (string severity in sevritylist) + if (SeverityList != null && SeverityList.Any()) { - ActionResult = Violationseverity.Any(y => y.Equals(severity)); + List<string> sevritylist = SeverityList.Select(x => x.Value.ToLower()).ToList(); + foreach (string severity in sevritylist) + { + ActionResult = Violationseverity.Any(y => y.Equals(severity)); + } + } + else + { + ActionResult = Violationseverity.Any(); } + } + var jsonresponse = JsonConvert.SerializeObject(axeResult, Newtonsoft.Json.Formatting.Indented); RawResponseValues = jsonresponse; AddOrUpdateReturnParamActual(ParamName: "Raw Response", ActualValue: jsonresponse); @@ -884,6 +951,8 @@ public void SetAxeResultToAction(AxeResult axeResult) Status = eRunStatus.Passed; } } + + } internal static class EmbeddedResourceProvider diff --git a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/AccessibilityTestResources/AccessiblityRules.json b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/AccessibilityTestResources/AccessiblityRules.json new file mode 100644 index 0000000000..d543b1b93b --- /dev/null +++ b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/AccessibilityTestResources/AccessiblityRules.json @@ -0,0 +1,740 @@ +{ + "accessibilityRules": [ + { + "RuleID": "area-alt", + "Description": "Ensure <area> elements of image maps have alternate text", + "Impact": "Critical", + "Tags": "cat.text-alternatives, wcag2a, wcag244, wcag412, section508, section508.22.a, TTv5, TT6.a, EN-301-549, EN-9.2.4.4, EN-9.4.1.2, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "c487ae" + }, + { + "RuleID": "aria-allowed-attr", + "Description": "Ensure an element's role supports its ARIA attributes", + "Impact": "Critical", + "Tags": "cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2", + "Issue Type": "failure, needs review", + "ACT Rules": "5c01ea" + }, + { + "RuleID": "aria-braille-equivalent", + "Description": "Ensure aria-braillelabel and aria-brailleroledescription have a non-braille equivalent", + "Impact": "Serious", + "Tags": "cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2", + "Issue Type": "needs review", + "ACT Rules": "" + }, + { + "RuleID": "aria-command-name", + "Description": "Ensure every ARIA button, link and menuitem has an accessible name", + "Impact": "Serious", + "Tags": "cat.aria, wcag2a, wcag412, TTv5, TT6.a, EN-301-549, EN-9.4.1.2, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "97a4e1" + }, + { + "RuleID": "aria-conditional-attr", + "Description": "Ensure ARIA attributes are used as described in the specification of the element's role", + "Impact": "Serious", + "Tags": "cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2", + "Issue Type": "failure", + "ACT Rules": "5c01ea" + }, + { + "RuleID": "aria-deprecated-role", + "Description": "Ensure elements do not use deprecated roles", + "Impact": "Minor", + "Tags": "cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2", + "Issue Type": "failure", + "ACT Rules": "674b10" + }, + { + "RuleID": "aria-hidden-body", + "Description": "Ensure aria-hidden=\"\"true\"\" is not present on the document body.", + "Impact": "Critical", + "Tags": "cat.aria, wcag2a, wcag131, wcag412, EN-301-549, EN-9.1.3.1, EN-9.4.1.2", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "aria-hidden-focus", + "Description": "Ensure aria-hidden elements are not focusable nor contain focusable elements", + "Impact": "Serious", + "Tags": "cat.name-role-value, wcag2a, wcag412, TTv5, TT6.a, EN-301-549, EN-9.4.1.2", + "Issue Type": "failure, needs review", + "ACT Rules": "6cfa84" + }, + { + "RuleID": "aria-input-field-name", + "Description": "Ensure every ARIA input field has an accessible name", + "Impact": "Serious", + "Tags": "cat.aria, wcag2a, wcag412, TTv5, TT5.c, EN-301-549, EN-9.4.1.2, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "e086e5" + }, + { + "RuleID": "aria-meter-name", + "Description": "Ensure every ARIA meter node has an accessible name", + "Impact": "Serious", + "Tags": "cat.aria, wcag2a, wcag111, EN-301-549, EN-9.1.1.1", + "Issue Type": "failure, needs review", + "ACT Rules": "" + }, + { + "RuleID": "aria-progressbar-name", + "Description": "Ensure every ARIA progressbar node has an accessible name", + "Impact": "Serious", + "Tags": "cat.aria, wcag2a, wcag111, EN-301-549, EN-9.1.1.1", + "Issue Type": "failure, needs review", + "ACT Rules": "" + }, + { + "RuleID": "aria-prohibited-attr", + "Description": "Ensure ARIA attributes are not prohibited for an element's role", + "Impact": "Serious", + "Tags": "cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2", + "Issue Type": "failure, needs review", + "ACT Rules": "5c01ea" + }, + { + "RuleID": "aria-required-attr", + "Description": "Ensure elements with ARIA roles have all required ARIA attributes", + "Impact": "Critical", + "Tags": "cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2", + "Issue Type": "failure", + "ACT Rules": "4e8ab6" + }, + { + "RuleID": "aria-required-children", + "Description": "Ensure elements with an ARIA role that require child roles contain them", + "Impact": "Critical", + "Tags": "cat.aria, wcag2a, wcag131, EN-301-549, EN-9.1.3.1", + "Issue Type": "failure, needs review", + "ACT Rules": "bc4a75, ff89c9" + }, + { + "RuleID": "aria-required-parent", + "Description": "Ensure elements with an ARIA role that require parent roles are contained by them", + "Impact": "Critical", + "Tags": "cat.aria, wcag2a, wcag131, EN-301-549, EN-9.1.3.1", + "Issue Type": "failure", + "ACT Rules": "ff89c9" + }, + { + "RuleID": "aria-roles", + "Description": "Ensure all elements with a role attribute use a valid value", + "Impact": "Critical", + "Tags": "cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2", + "Issue Type": "failure", + "ACT Rules": "674b10" + }, + { + "RuleID": "aria-toggle-field-name", + "Description": "Ensure every ARIA toggle field has an accessible name", + "Impact": "Serious", + "Tags": "cat.aria, wcag2a, wcag412, TTv5, TT5.c, EN-301-549, EN-9.4.1.2, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "e086e5" + }, + { + "RuleID": "aria-tooltip-name", + "Description": "Ensure every ARIA tooltip node has an accessible name", + "Impact": "Serious", + "Tags": "cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2", + "Issue Type": "failure, needs review", + "ACT Rules": "" + }, + { + "RuleID": "aria-valid-attr-value", + "Description": "Ensure all ARIA attributes have valid values", + "Impact": "Critical", + "Tags": "cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2", + "Issue Type": "failure, needs review", + "ACT Rules": "6a7281" + }, + { + "RuleID": "aria-valid-attr", + "Description": "Ensure attributes that begin with aria- are valid ARIA attributes", + "Impact": "Critical", + "Tags": "cat.aria, wcag2a, wcag412, EN-301-549, EN-9.4.1.2", + "Issue Type": "failure", + "ACT Rules": "5f99a7" + }, + { + "RuleID": "blink", + "Description": "Ensure <blink> elements are not used", + "Impact": "Serious", + "Tags": "cat.time-and-media, wcag2a, wcag222, section508, section508.22.j, TTv5, TT2.b, EN-301-549, EN-9.2.2.2", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "button-name", + "Description": "Ensure buttons have discernible text", + "Impact": "Critical", + "Tags": "cat.name-role-value, wcag2a, wcag412, section508, section508.22.a, TTv5, TT6.a, EN-301-549, EN-9.4.1.2, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "97a4e1, m6b1q3" + }, + { + "RuleID": "bypass", + "Description": "Ensure each page has at least one mechanism for a user to bypass navigation and jump straight to the content", + "Impact": "Serious", + "Tags": "cat.keyboard, wcag2a, wcag241, section508, section508.22.o, TTv5, TT9.a, EN-301-549, EN-9.2.4.1", + "Issue Type": "needs review", + "ACT Rules": "cf77f2, 047fe0, b40fd1, 3e12e1, ye5d6e" + }, + { + "RuleID": "color-contrast", + "Description": "Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds", + "Impact": "Serious", + "Tags": "cat.color, wcag2aa, wcag143, TTv5, TT13.c, EN-301-549, EN-9.1.4.3, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "afw4f7, 09o5cg" + }, + { + "RuleID": "definition-list", + "Description": "Ensure <dl> elements are structured correctly", + "Impact": "Serious", + "Tags": "cat.structure, wcag2a, wcag131, EN-301-549, EN-9.1.3.1", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "dlitem", + "Description": "Ensure <dt> and <dd> elements are contained by a <dl>", + "Impact": "Serious", + "Tags": "cat.structure, wcag2a, wcag131, EN-301-549, EN-9.1.3.1", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "document-title", + "Description": "Ensure each HTML document contains a non-empty <title> element", + "Impact": "Serious", + "Tags": "cat.text-alternatives, wcag2a, wcag242, TTv5, TT12.a, EN-301-549, EN-9.2.4.2, ACT", + "Issue Type": "failure", + "ACT Rules": "2779a5" + }, + { + "RuleID": "duplicate-id-aria", + "Description": "Ensure every id attribute value used in ARIA and in labels is unique", + "Impact": "Critical", + "Tags": "cat.parsing, wcag2a, wcag412, EN-301-549, EN-9.4.1.2", + "Issue Type": "needs review", + "ACT Rules": "3ea0c8" + }, + { + "RuleID": "form-field-multiple-labels", + "Description": "Ensure form field does not have multiple label elements", + "Impact": "Moderate", + "Tags": "cat.forms, wcag2a, wcag332, TTv5, TT5.c, EN-301-549, EN-9.3.3.2", + "Issue Type": "needs review", + "ACT Rules": "" + }, + { + "RuleID": "frame-focusable-content", + "Description": "Ensure <frame> and <iframe> elements with focusable content do not have tabindex=-1", + "Impact": "Serious", + "Tags": "cat.keyboard, wcag2a, wcag211, TTv5, TT4.a, EN-301-549, EN-9.2.1.1", + "Issue Type": "failure, needs review", + "ACT Rules": "akn7bn" + }, + { + "RuleID": "frame-title-unique", + "Description": "Ensure <iframe> and <frame> elements contain a unique title attribute", + "Impact": "Serious", + "Tags": "cat.text-alternatives, wcag2a, wcag412, TTv5, TT12.d, EN-301-549, EN-9.4.1.2", + "Issue Type": "needs review", + "ACT Rules": "4b1c6c" + }, + { + "RuleID": "frame-title", + "Description": "Ensure <iframe> and <frame> elements have an accessible name", + "Impact": "Serious", + "Tags": "cat.text-alternatives, wcag2a, wcag412, section508, section508.22.i, TTv5, TT12.d, EN-301-549, EN-9.4.1.2", + "Issue Type": "failure, needs review", + "ACT Rules": "cae760" + }, + { + "RuleID": "html-has-lang", + "Description": "Ensure every HTML document has a lang attribute", + "Impact": "Serious", + "Tags": "cat.language, wcag2a, wcag311, TTv5, TT11.a, EN-301-549, EN-9.3.1.1, ACT", + "Issue Type": "failure", + "ACT Rules": "b5c3f8" + }, + { + "RuleID": "html-lang-valid", + "Description": "Ensure the lang attribute of the <html> element has a valid value", + "Impact": "Serious", + "Tags": "cat.language, wcag2a, wcag311, TTv5, TT11.a, EN-301-549, EN-9.3.1.1, ACT", + "Issue Type": "failure", + "ACT Rules": "bf051a" + }, + { + "RuleID": "html-xml-lang-mismatch", + "Description": "Ensure that HTML elements with both valid lang and xml:lang attributes agree on the base language of the page", + "Impact": "Moderate", + "Tags": "cat.language, wcag2a, wcag311, EN-301-549, EN-9.3.1.1, ACT", + "Issue Type": "failure", + "ACT Rules": "5b7ae0" + }, + { + "RuleID": "image-alt", + "Description": "Ensure <img> elements have alternate text or a role of none or presentation", + "Impact": "Critical", + "Tags": "cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a, TTv5, TT7.a, TT7.b, EN-301-549, EN-9.1.1.1, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "23a2a8" + }, + { + "RuleID": "input-button-name", + "Description": "Ensure input buttons have discernible text", + "Impact": "Critical", + "Tags": "cat.name-role-value, wcag2a, wcag412, section508, section508.22.a, TTv5, TT5.c, EN-301-549, EN-9.4.1.2, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "97a4e1" + }, + { + "RuleID": "input-image-alt", + "Description": "Ensure <input type=\"\"image\"\"> elements have alternate text", + "Impact": "Critical", + "Tags": "cat.text-alternatives, wcag2a, wcag111, wcag412, section508, section508.22.a, TTv5, TT7.a, EN-301-549, EN-9.1.1.1, EN-9.4.1.2, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "59796f" + }, + { + "RuleID": "label", + "Description": "Ensure every form element has a label", + "Impact": "Critical", + "Tags": "cat.forms, wcag2a, wcag412, section508, section508.22.n, TTv5, TT5.c, EN-301-549, EN-9.4.1.2, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "e086e5" + }, + { + "RuleID": "link-in-text-block", + "Description": "Ensure links are distinguished from surrounding text in a way that does not rely on color", + "Impact": "Serious", + "Tags": "cat.color, wcag2a, wcag141, TTv5, TT13.a, EN-301-549, EN-9.1.4.1", + "Issue Type": "failure, needs review", + "ACT Rules": "" + }, + { + "RuleID": "link-name", + "Description": "Ensure links have discernible text", + "Impact": "Serious", + "Tags": "cat.name-role-value, wcag2a, wcag244, wcag412, section508, section508.22.a, TTv5, TT6.a, EN-301-549, EN-9.2.4.4, EN-9.4.1.2, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "c487ae" + }, + { + "RuleID": "list", + "Description": "Ensure that lists are structured correctly", + "Impact": "Serious", + "Tags": "cat.structure, wcag2a, wcag131, EN-301-549, EN-9.1.3.1", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "listitem", + "Description": "Ensure <li> elements are used semantically", + "Impact": "Serious", + "Tags": "cat.structure, wcag2a, wcag131, EN-301-549, EN-9.1.3.1", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "marquee", + "Description": "Ensure <marquee> elements are not used", + "Impact": "Serious", + "Tags": "cat.parsing, wcag2a, wcag222, TTv5, TT2.b, EN-301-549, EN-9.2.2.2", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "meta-refresh", + "Description": "Ensure <meta http-equiv=\"\"refresh\"\"> is not used for delayed refresh", + "Impact": "Critical", + "Tags": "cat.time-and-media, wcag2a, wcag221, TTv5, TT8.a, EN-301-549, EN-9.2.2.1", + "Issue Type": "failure", + "ACT Rules": "bc659a, bisz58" + }, + { + "RuleID": "meta-viewport", + "Description": "Ensure <meta name=\"\"viewport\"\"> does not disable text scaling and zooming", + "Impact": "Critical", + "Tags": "cat.sensory-and-visual-cues, wcag2aa, wcag144, EN-301-549, EN-9.1.4.4, ACT", + "Issue Type": "failure", + "ACT Rules": "b4f0c3" + }, + { + "RuleID": "nested-interactive", + "Description": "Ensure interactive controls are not nested as they are not always announced by screen readers or can cause focus problems for assistive technologies", + "Impact": "Serious", + "Tags": "cat.keyboard, wcag2a, wcag412, TTv5, TT6.a, EN-301-549, EN-9.4.1.2", + "Issue Type": "failure, needs review", + "ACT Rules": "307n5z" + }, + { + "RuleID": "no-autoplay-audio", + "Description": "Ensure <video> or <audio> elements do not autoplay audio for more than 3 seconds without a control mechanism to stop or mute the audio", + "Impact": "Moderate", + "Tags": "cat.time-and-media, wcag2a, wcag142, TTv5, TT2.a, EN-301-549, EN-9.1.4.2, ACT", + "Issue Type": "needs review", + "ACT Rules": "80f0bf" + }, + { + "RuleID": "object-alt", + "Description": "Ensure <object> elements have alternate text", + "Impact": "Serious", + "Tags": "cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a, EN-301-549, EN-9.1.1.1", + "Issue Type": "failure, needs review", + "ACT Rules": "8fc3b6" + }, + { + "RuleID": "role-img-alt", + "Description": "Ensure [role=\"\"img\"\"] elements have alternate text", + "Impact": "Serious", + "Tags": "cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a, TTv5, TT7.a, EN-301-549, EN-9.1.1.1, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "23a2a8" + }, + { + "RuleID": "scrollable-region-focusable", + "Description": "Ensure elements that have scrollable content are accessible by keyboard", + "Impact": "Serious", + "Tags": "cat.keyboard, wcag2a, wcag211, wcag213, TTv5, TT4.a, EN-301-549, EN-9.2.1.1, EN-9.2.1.3", + "Issue Type": "failure", + "ACT Rules": "0ssw9k" + }, + { + "RuleID": "select-name", + "Description": "Ensure select element has an accessible name", + "Impact": "Critical", + "Tags": "cat.forms, wcag2a, wcag412, section508, section508.22.n, TTv5, TT5.c, EN-301-549, EN-9.4.1.2, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "e086e5" + }, + { + "RuleID": "server-side-image-map", + "Description": "Ensure that server-side image maps are not used", + "Impact": "Minor", + "Tags": "cat.text-alternatives, wcag2a, wcag211, section508, section508.22.f, TTv5, TT4.a, EN-301-549, EN-9.2.1.1", + "Issue Type": "needs review", + "ACT Rules": "" + }, + { + "RuleID": "svg-img-alt", + "Description": "Ensure <svg> elements with an img, graphics-document or graphics-symbol role have an accessible text", + "Impact": "Serious", + "Tags": "cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a, TTv5, TT7.a, EN-301-549, EN-9.1.1.1, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "7d6734" + }, + { + "RuleID": "td-headers-attr", + "Description": "Ensure that each cell in a table that uses the headers attribute refers only to other cells in that table", + "Impact": "Serious", + "Tags": "cat.tables, wcag2a, wcag131, section508, section508.22.g, TTv5, TT14.b, EN-301-549, EN-9.1.3.1", + "Issue Type": "failure, needs review", + "ACT Rules": "a25f45" + }, + { + "RuleID": "th-has-data-cells", + "Description": "Ensure that <th> elements and elements with role=columnheader/rowheader have data cells they describe", + "Impact": "Serious", + "Tags": "cat.tables, wcag2a, wcag131, section508, section508.22.g, TTv5, TT14.b, EN-301-549, EN-9.1.3.1", + "Issue Type": "failure, needs review", + "ACT Rules": "d0f69e" + }, + { + "RuleID": "valid-lang", + "Description": "Ensure lang attributes have valid values", + "Impact": "Serious", + "Tags": "cat.language, wcag2aa, wcag312, TTv5, TT11.b, EN-301-549, EN-9.3.1.2, ACT", + "Issue Type": "failure", + "ACT Rules": "de46e4" + }, + { + "RuleID": "video-caption", + "Description": "Ensure <video> elements have captions", + "Impact": "Critical", + "Tags": "cat.text-alternatives, wcag2a, wcag122, section508, section508.22.a, TTv5, TT17.a, EN-301-549, EN-9.1.2.2", + "Issue Type": "needs review", + "ACT Rules": "eac66b" + }, + { + "RuleID": "autocomplete-valid", + "Description": "Ensure the autocomplete attribute is correct and suitable for the form field", + "Impact": "Serious", + "Tags": "cat.forms, wcag21aa, wcag135, EN-301-549, EN-9.1.3.5, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "73f2c2" + }, + { + "RuleID": "avoid-inline-spacing", + "Description": "Ensure that text spacing set through style attributes can be adjusted with custom stylesheets", + "Impact": "Serious", + "Tags": "cat.structure, wcag21aa, wcag1412, EN-301-549, EN-9.1.4.12, ACT", + "Issue Type": "failure", + "ACT Rules": "24afc2, 9e45ec, 78fd32" + }, + { + "RuleID": "target-size", + "Description": "Ensure touch targets have sufficient size and space", + "Impact": "Serious", + "Tags": "cat.sensory-and-visual-cues, wcag22aa, wcag258", + "Issue Type": "failure, needs review", + "ACT Rules": "" + }, + { + "RuleID": "accesskeys", + "Description": "Ensure every accesskey attribute value is unique", + "Impact": "Serious", + "Tags": "cat.keyboard, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "aria-allowed-role", + "Description": "Ensure role attribute has an appropriate value for the element", + "Impact": "Minor", + "Tags": "cat.aria, best-practice", + "Issue Type": "failure, needs review", + "ACT Rules": "" + }, + { + "RuleID": "aria-dialog-name", + "Description": "Ensure every ARIA dialog and alertdialog node has an accessible name", + "Impact": "Serious", + "Tags": "cat.aria, best-practice", + "Issue Type": "failure, needs review", + "ACT Rules": "" + }, + { + "RuleID": "aria-text", + "Description": "Ensure role=\"\"text\"\" is used on elements with no focusable descendants", + "Impact": "Serious", + "Tags": "cat.aria, best-practice", + "Issue Type": "failure, needs review", + "ACT Rules": "" + }, + { + "RuleID": "aria-treeitem-name", + "Description": "Ensure every ARIA treeitem node has an accessible name", + "Impact": "Serious", + "Tags": "cat.aria, best-practice", + "Issue Type": "failure, needs review", + "ACT Rules": "" + }, + { + "RuleID": "empty-heading", + "Description": "Ensure headings have discernible text", + "Impact": "Minor", + "Tags": "cat.name-role-value, best-practice", + "Issue Type": "failure, needs review", + "ACT Rules": "ffd0e9" + }, + { + "RuleID": "empty-table-header", + "Description": "Ensure table headers have discernible text", + "Impact": "Minor", + "Tags": "cat.name-role-value, best-practice", + "Issue Type": "failure, needs review", + "ACT Rules": "" + }, + { + "RuleID": "frame-tested", + "Description": "Ensure <iframe> and <frame> elements contain the axe-core script", + "Impact": "Critical", + "Tags": "cat.structure, best-practice, review-item", + "Issue Type": "failure, needs review", + "ACT Rules": "" + }, + { + "RuleID": "heading-order", + "Description": "Ensure the order of headings is semantically correct", + "Impact": "Moderate", + "Tags": "cat.semantics, best-practice", + "Issue Type": "failure, needs review", + "ACT Rules": "" + }, + { + "RuleID": "image-redundant-alt", + "Description": "Ensure image alternative is not repeated as text", + "Impact": "Minor", + "Tags": "cat.text-alternatives, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "label-title-only", + "Description": "Ensure that every form element has a visible label and is not solely labeled using hidden labels, or the title or aria-describedby attributes", + "Impact": "Serious", + "Tags": "cat.forms, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "landmark-banner-is-top-level", + "Description": "Ensure the banner landmark is at top level", + "Impact": "Moderate", + "Tags": "cat.semantics, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "landmark-complementary-is-top-level", + "Description": "Ensure the complementary landmark or aside is at top level", + "Impact": "Moderate", + "Tags": "cat.semantics, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "landmark-contentinfo-is-top-level", + "Description": "Ensure the contentinfo landmark is at top level", + "Impact": "Moderate", + "Tags": "cat.semantics, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "landmark-main-is-top-level", + "Description": "Ensure the main landmark is at top level", + "Impact": "Moderate", + "Tags": "cat.semantics, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "landmark-no-duplicate-banner", + "Description": "Ensure the document has at most one banner landmark", + "Impact": "Moderate", + "Tags": "cat.semantics, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "landmark-no-duplicate-contentinfo", + "Description": "Ensure the document has at most one contentinfo landmark", + "Impact": "Moderate", + "Tags": "cat.semantics, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "landmark-no-duplicate-main", + "Description": "Ensure the document has at most one main landmark", + "Impact": "Moderate", + "Tags": "cat.semantics, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "landmark-one-main", + "Description": "Ensure the document has a main landmark", + "Impact": "Moderate", + "Tags": "cat.semantics, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "landmark-unique", + "Description": "Ensure landmarks are unique", + "Impact": "Moderate", + "Tags": "cat.semantics, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "meta-viewport-large", + "Description": "Ensure <meta name=\"\"viewport\"\"> can scale a significant amount", + "Impact": "Minor", + "Tags": "cat.sensory-and-visual-cues, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "page-has-heading-one", + "Description": "Ensure that the page, or at least one of its frames contains a level-one heading", + "Impact": "Moderate", + "Tags": "cat.semantics, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "presentation-role-conflict", + "Description": "Elements marked as presentational should not have global ARIA or tabindex to ensure all screen readers ignore them", + "Impact": "Minor", + "Tags": "cat.aria, best-practice, ACT", + "Issue Type": "failure", + "ACT Rules": "46ca7f" + }, + { + "RuleID": "region", + "Description": "Ensure all page content is contained by landmarks", + "Impact": "Moderate", + "Tags": "cat.keyboard, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "scope-attr-valid", + "Description": "Ensure the scope attribute is used correctly on tables", + "Impact": "Moderate", + "Tags": "cat.tables, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "skip-link", + "Description": "Ensure all skip links have a focusable target", + "Impact": "Moderate", + "Tags": "cat.keyboard, best-practice", + "Issue Type": "failure, needs review", + "ACT Rules": "" + }, + { + "RuleID": "tabindex", + "Description": "Ensure tabindex attribute values are not greater than 0", + "Impact": "Serious", + "Tags": "cat.keyboard, best-practice", + "Issue Type": "failure", + "ACT Rules": "" + }, + { + "RuleID": "table-duplicate-name", + "Description": "Ensure the <caption> element does not contain the same text as the summary attribute", + "Impact": "Minor", + "Tags": "cat.tables, best-practice", + "Issue Type": "failure, needs review", + "ACT Rules": "" + }, + { + "RuleID": "color-contrast-enhanced", + "Description": "Ensure the contrast between foreground and background colors meets WCAG 2 AAA enhanced contrast ratio thresholds", + "Impact": "Serious", + "Tags": "cat.color, wcag2aaa, wcag146, ACT", + "Issue Type": "failure, needs review", + "ACT Rules": "09o5cg" + }, + { + "RuleID": "identical-links-same-purpose", + "Description": "Ensure that links with the same accessible name serve a similar purpose", + "Impact": "Minor", + "Tags": "cat.semantics, wcag2aaa, wcag249", + "Issue Type": "needs review", + "ACT Rules": "b20e66" + }, + { + "RuleID": "meta-refresh-no-exceptions", + "Description": "Ensure <meta http-equiv=\"\"refresh\"\"> is not used for delayed refresh", + "Impact": "Minor", + "Tags": "cat.time-and-media, wcag2aaa, wcag224, wcag325", + "Issue Type": "failure", + "ACT Rules": "bisz58" + } + ] +} diff --git a/Ginger/GingerCoreNET/GeneralLib/General.cs b/Ginger/GingerCoreNET/GeneralLib/General.cs index 4ea3f75398..87dc093959 100644 --- a/Ginger/GingerCoreNET/GeneralLib/General.cs +++ b/Ginger/GingerCoreNET/GeneralLib/General.cs @@ -21,6 +21,7 @@ limitations under the License. using Amdocs.Ginger.Common.Repository.SolutionCategories; using Amdocs.Ginger.CoreNET.Run.SolutionCategory; using Amdocs.Ginger.Repository; +using Ginger.Configurations; using GingerCore; using GingerCore.Actions; using GingerCore.ALM; @@ -615,6 +616,28 @@ public static string CreateReportLinkPerFlow(string HtmlReportUrl, string Execut } return ""; } + + public static bool CreateDefaultAccessiblityconfiguration() + { + try + { + if (!WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<AccessibilityConfiguration>().Any()) + { + AccessibilityConfiguration newAccessibilityConfiguration = new AccessibilityConfiguration() { Name = "Accessibility" }; + WorkSpace.Instance.SolutionRepository.AddRepositoryItem(newAccessibilityConfiguration); + return true; + } + else + { + return false; + } + } + catch (Exception ex) + { + Reporter.ToLog(eLogLevel.ERROR, "Error creating default accessibility configuration", ex); + return false; + } + } } } diff --git a/Ginger/GingerCoreNET/GingerCoreNET.csproj b/Ginger/GingerCoreNET/GingerCoreNET.csproj index 5cc9ec4069..d82b9538aa 100644 --- a/Ginger/GingerCoreNET/GingerCoreNET.csproj +++ b/Ginger/GingerCoreNET/GingerCoreNET.csproj @@ -58,6 +58,7 @@ <None Remove="DLLS\SikuliStandardNet.dll" /> <None Remove="DLLS\ZephyrEntStdSDK.dll" /> <None Remove="DLLS\Zepyhr_Ent_Repository_Std.dll" /> + <None Remove="Drivers\CoreDrivers\Web\Selenium\AccessibilityTestResources\AccessiblityRules.json" /> <None Remove="Drivers\CoreDrivers\Web\Selenium\AccessibilityTestResources\htmlReporter.css" /> <None Remove="Drivers\CoreDrivers\Web\Selenium\AccessibilityTestResources\htmlReporterElements.js" /> <None Remove="Drivers\WebServicesDriver\WebServicesDriverWindow.xaml" /> @@ -204,6 +205,9 @@ <EmbeddedResource Include="DLLS\GingerHbaseFilter.dll"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </EmbeddedResource> + <EmbeddedResource Include="Drivers\CoreDrivers\Web\Selenium\AccessibilityTestResources\AccessiblityRules.json"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </EmbeddedResource> <EmbeddedResource Include="Drivers\CoreDrivers\Web\Selenium\AccessibilityTestResources\htmlReporterElements.js"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </EmbeddedResource> @@ -248,9 +252,9 @@ <PackageReference Include="CouchbaseNetClient" Version="2.7.11" /> - <PackageReference Include="Deque.AxeCore.Commons" Version="4.8.0" /> + <PackageReference Include="Deque.AxeCore.Commons" Version="4.9.1" /> - <PackageReference Include="Deque.AxeCore.Selenium" Version="4.8.0" /> + <PackageReference Include="Deque.AxeCore.Selenium" Version="4.9.1" /> <PackageReference Include="EnterpriseLibrary.TransientFaultHandling" Version="6.0.1304" /> diff --git a/Ginger/GingerCoreNET/WorkSpaceLib/WorkSpace.cs b/Ginger/GingerCoreNET/WorkSpaceLib/WorkSpace.cs index 7886fc61e7..4f2c88c273 100644 --- a/Ginger/GingerCoreNET/WorkSpaceLib/WorkSpace.cs +++ b/Ginger/GingerCoreNET/WorkSpaceLib/WorkSpace.cs @@ -414,6 +414,7 @@ private void CheckForExistingEnterpriseFeaturesConfiguration() { WorkSpace.Instance.UserProfile.ShowEnterpriseFeatures = true; } + } public bool OpenSolution(string solutionFolder, string encryptionKey = null) diff --git a/Ginger/GingerCoreNETUnitTest/ActionsLib/UI/Web/AccessiblityTests.cs b/Ginger/GingerCoreNETUnitTest/ActionsLib/UI/Web/AccessiblityTests.cs new file mode 100644 index 0000000000..f2abb5c965 --- /dev/null +++ b/Ginger/GingerCoreNETUnitTest/ActionsLib/UI/Web/AccessiblityTests.cs @@ -0,0 +1,208 @@ +#region License +/* +Copyright © 2014-2024 European Support Limited + +Licensed under the Apache License, Version 2.0 (the "License") +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +#endregion + +using amdocs.ginger.GingerCoreNET; +using Amdocs.Ginger.Common; +using Amdocs.Ginger.Common.VariablesLib; +using Amdocs.Ginger.CoreNET.ActionsLib.UI.Web; +using Amdocs.Ginger.Repository; +using Deque.AxeCore.Selenium; +using Ginger.AnalyzerLib; +using Ginger.Configurations; +using GingerCore; +using GingerCoreNETUnitTest.WorkSpaceLib; +using GingerTestHelper; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OfficeOpenXml.Attributes; +using OpenQA.Selenium; +using OpenQA.Selenium.Chrome; +using System; +using System.IO; +using System.Linq; +using System.Runtime.Versioning; + +namespace GingerCoreNETUnitTest.ActionsLib.UI.Web +{ + [TestClass] + [TestCategory(TestCategory.IntegrationTest)] + public class AccessiblityTests + { + + private static IWebDriver _driver; + IWebElement e = null; + + [ClassInitialize()] + public static void ClassInit(TestContext TC) + { + if (!OperatingSystem.IsWindows()) + { + return; + } + _driver = new ChromeDriver(); + } + + [ClassCleanup] + public static void ClassCleanup() + { + _driver.Quit(); + } + + public static void InitDriver() + { + //// Initialize the WebDriver (Chrome in this case) + _driver = new ChromeDriver(); + } + public static void CleanDriver() + { + _driver.Quit(); + } + + [TestMethod] + [TestProperty("ExecutionOrder", "1")] + public void TestAnalyzerAccessibility_Standard_Failed() + { + if (!OperatingSystem.IsWindows()) + { + return; + } + _driver.Navigate().GoToUrl($"https://ginger.amdocs.com/"); + ActAccessibilityTesting mact = new ActAccessibilityTesting(); + mact.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Target, ActAccessibilityTesting.eTarget.Page); + mact.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Analyzer, ActAccessibilityTesting.eAnalyzer.ByStandard); + if (mact.GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == nameof(ActAccessibilityTesting.eAnalyzer.ByStandard)) + { + mact.SeverityList = new ObservableList<OperationValues>(); + mact.StandardList = GetStandardTagslist(); + } + mact.AnalyzerAccessibility(_driver, e); + Assert.AreEqual(mact.Status,Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed); + } + + [TestMethod] + [TestProperty("ExecutionOrder", "2")] + public void TestAnalyzerAccessibility_Severity_Failed() + { + if (!OperatingSystem.IsWindows()) + { + return; + } + _driver.Navigate().GoToUrl($"https://ginger.amdocs.com/"); + ActAccessibilityTesting mact = new ActAccessibilityTesting(); + mact.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Target, ActAccessibilityTesting.eTarget.Page); + mact.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Analyzer, ActAccessibilityTesting.eAnalyzer.BySeverity); + if (mact.GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == nameof(ActAccessibilityTesting.eAnalyzer.BySeverity)) + { + mact.SeverityList = GetSeverityList(); + mact.SeverityList.RemoveAt(1); + } + mact.AnalyzerAccessibility(_driver, e); + Assert.AreEqual(mact.Status, Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed); + } + [TestMethod] + [TestProperty("ExecutionOrder", "3")] + public void TestAnalyzerAccessibility_Standard_Pass() + { + if (!OperatingSystem.IsWindows()) + { + return; + } + string htmlFilePath = Path.Combine(TestResources.GetTestResourcesFolder("Html"), "TestAccessiblity.html"); + _driver.Navigate().GoToUrl(htmlFilePath); + ActAccessibilityTesting mact = new ActAccessibilityTesting(); + mact.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Target, ActAccessibilityTesting.eTarget.Page); + mact.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Analyzer, ActAccessibilityTesting.eAnalyzer.ByStandard); + if (mact.GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == nameof(ActAccessibilityTesting.eAnalyzer.ByStandard)) + { + mact.SeverityList = new ObservableList<OperationValues>(); + mact.StandardList = GetStandardTagslist(); + } + mact.AnalyzerAccessibility(_driver, e); + Assert.AreEqual(mact.Status, Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed); + } + [TestMethod] + [TestProperty("ExecutionOrder", "4")] + public void TestAnalyzerAccessibility_Severity_Pass() + { + if (!OperatingSystem.IsWindows()) + { + return; + } + string htmlFilePath = Path.Combine(TestResources.GetTestResourcesFolder("Html"), "TestAccessiblity.html"); + _driver.Navigate().GoToUrl(htmlFilePath); + ActAccessibilityTesting mact = new ActAccessibilityTesting(); + mact.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Target, ActAccessibilityTesting.eTarget.Page); + mact.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Analyzer, ActAccessibilityTesting.eAnalyzer.BySeverity); + if (mact.GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == nameof(ActAccessibilityTesting.eAnalyzer.BySeverity)) + { + mact.SeverityList = GetSeverityList(); + mact.SeverityList.RemoveAt(1); + } + mact.AnalyzerAccessibility(_driver, e); + Assert.AreEqual(mact.Status, Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed); + } + [TestMethod] + [TestCategory(TestCategory.UnitTest)] + public void TestCreateAxeBuilder_IsNotNull() + { + if (!OperatingSystem.IsWindows()) + { + return; + } + ActAccessibilityTesting mact = new ActAccessibilityTesting(); + AxeBuilder axeBuilder = mact.CreateAxeBuilder(_driver); + Assert.AreNotEqual(null, axeBuilder); + } + [TestMethod] + [TestCategory(TestCategory.UnitTest)] + public void TestGetRuleList_isNotNull() + { + if (!OperatingSystem.IsWindows()) + { + return; + } + ActAccessibilityTesting mact = new ActAccessibilityTesting(); + ObservableList<AccessibilityRuleData> ruleList = mact.GetRuleList(); + Assert.AreNotEqual(null, ruleList); + Assert.AreEqual(92, ruleList.Count); + } + + public static ObservableList<OperationValues> GetStandardTagslist() + { + ObservableList<OperationValues> StandardTagList = new ObservableList<OperationValues>(); + StandardTagList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eTags.wcag2a) }); + StandardTagList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eTags.wcag2aa) }); + StandardTagList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eTags.wcag21a) }); + StandardTagList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eTags.wcag21aa) }); + StandardTagList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eTags.wcag22a) }); + StandardTagList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eTags.wcag22aa) }); + StandardTagList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eTags.bestpractice) }); + return StandardTagList; + } + + public static ObservableList<OperationValues> GetSeverityList() + { + ObservableList<OperationValues> SeverityList = new ObservableList<OperationValues>(); + + SeverityList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eSeverity.Critical) }); + SeverityList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eSeverity.Serious) }); + SeverityList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eSeverity.Moderate) }); + SeverityList.Add(new OperationValues() { Value = nameof(ActAccessibilityTesting.eSeverity.Minor) }); + return SeverityList; + } + } +} diff --git a/Ginger/GingerCoreNETUnitTest/GingerCoreNETUnitTest.csproj b/Ginger/GingerCoreNETUnitTest/GingerCoreNETUnitTest.csproj index 5ba673c587..9fd4e120e4 100644 --- a/Ginger/GingerCoreNETUnitTest/GingerCoreNETUnitTest.csproj +++ b/Ginger/GingerCoreNETUnitTest/GingerCoreNETUnitTest.csproj @@ -29,6 +29,7 @@ <None Remove="TestResources\Files\ScriptWithGingerOutput.vbs" /> <None Remove="TestResources\Files\ScriptWithGingerOutputIndexZero.vbs" /> <None Remove="TestResources\Files\ScriptWithoutOutput.vbs" /> + <None Remove="TestResources\Html\TestAccessiblity.html" /> <None Remove="TestResources\JSON\Request JSON.TXT" /> <None Remove="TestResources\Repository\Default Run Set.Ginger.RunSetConfig.xml" /> <None Remove="TestResources\Repository\dummyAction.xml" /> @@ -50,6 +51,9 @@ <Content Include="TestResources\Files\ScriptWithoutOutput.vbs"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> + <Content Include="TestResources\Html\TestAccessiblity.html"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> <Content Include="TestResources\JSON\Request JSON.TXT"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> diff --git a/Ginger/GingerCoreNETUnitTest/TestResources/Html/TestAccessiblity.html b/Ginger/GingerCoreNETUnitTest/TestResources/Html/TestAccessiblity.html new file mode 100644 index 0000000000..ee0bfae26b --- /dev/null +++ b/Ginger/GingerCoreNETUnitTest/TestResources/Html/TestAccessiblity.html @@ -0,0 +1,78 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Accessibility Testing Page + + + +
+

Accessibility Testing Page

+ +
+ +
+
+

Section 1: Images

+ A descriptive text about the image + +
+ +
+

Section 2: Links and Buttons

+

Visit the example website for more information.

+ +
+ +
+

Form

+
+ + +

+ + +

+
+ Gender + + +
+
+ +
+
+ +
+

Keyboard Navigation

+

Use Tab and Shift + Tab to navigate through interactive elements.

+
+
+ + + +