diff --git a/Ginger/Ginger/Actions/ActionsListViewPage.xaml.cs b/Ginger/Ginger/Actions/ActionsListViewPage.xaml.cs index 486834437e..97be822ccf 100644 --- a/Ginger/Ginger/Actions/ActionsListViewPage.xaml.cs +++ b/Ginger/Ginger/Actions/ActionsListViewPage.xaml.cs @@ -194,7 +194,7 @@ private void SetListView() mActionsListHelper.ActionListItemEvent += MActionListItemInfo_ActionListItemEvent; mActionsListView.SetDefaultListDataTemplate(mActionsListHelper); - + mActionsListView.ListSelectionMode = SelectionMode.Extended; mActionsListView.PreviewDragItem += listActions_PreviewDragItem; @@ -204,10 +204,6 @@ private void SetListView() // Enable Virtualization for Actions ListView to improve the loading time/performance mActionsListView.List.SetValue(ScrollViewer.CanContentScrollProperty, true); - if (mPageViewMode == Ginger.General.eRIPageViewMode.View || mPageViewMode == Ginger.General.eRIPageViewMode.ViewAndExecute) - { - mActionsListView.IsDragDropCompatible = false; - } } else { @@ -219,6 +215,15 @@ private void SetListView() } } + if (mPageViewMode == Ginger.General.eRIPageViewMode.View || mPageViewMode == Ginger.General.eRIPageViewMode.ViewAndExecute) + { + mActionsListView.IsDragDropCompatible = false; + } + else + { + mActionsListView.IsDragDropCompatible = true; + } + if (mActivity != null) { //update actions platform diff --git a/Ginger/Ginger/Ginger.csproj b/Ginger/Ginger/Ginger.csproj index e02aa55d86..7ab283ddaf 100644 --- a/Ginger/Ginger/Ginger.csproj +++ b/Ginger/Ginger/Ginger.csproj @@ -707,7 +707,7 @@ - + diff --git a/Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml.cs b/Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml.cs index 9950bbbcce..1224a4d8b4 100644 --- a/Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml.cs +++ b/Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml.cs @@ -110,25 +110,30 @@ private void CheckBox_Click(object sender, RoutedEventArgs e) // Do something with data, for example: data.Active = checkBox.IsChecked ?? false; mAccessibilityConfiguration.StartDirtyTracking(); - if (!data.Active) + if (!mAccessibilityConfiguration.ExcludedRules.Any()) { - if(!mAccessibilityConfiguration.ExcludedRules.Any()) - { - GingerCoreNET.GeneralLib.General.CreateDefaultAccessiblityconfiguration(); - mAccessibilityConfiguration = WorkSpace.Instance.SolutionRepository.GetFirstRepositoryItem(); - mAccessibilityConfiguration.ExcludedRules = mAccessibilityConfiguration.ExcludedRules != null ? mAccessibilityConfiguration.ExcludedRules : new(); - } + 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))) + if (!data.Active) + { + if (!mAccessibilityConfiguration.ExcludedRules.Any(x => x.RuleID.Equals(data.RuleID,StringComparison.CurrentCultureIgnoreCase))) { mAccessibilityConfiguration.ExcludedRules.Add(data); } } else { - if (mAccessibilityConfiguration.ExcludedRules.Any(x => x.Equals(data.RuleID))) + if (mAccessibilityConfiguration.ExcludedRules.Any(x => x.RuleID.Equals(data.RuleID,StringComparison.CurrentCultureIgnoreCase))) { - mAccessibilityConfiguration.ExcludedRules.Remove(data); + AccessibilityRuleData itemToRemove = mAccessibilityConfiguration.ExcludedRules.FirstOrDefault(x => x.RuleID.Equals(data.RuleID, StringComparison.CurrentCultureIgnoreCase)); + if (itemToRemove != null) + { + mAccessibilityConfiguration.ExcludedRules.Remove(itemToRemove); + } + } } } diff --git a/Ginger/GingerCoreCommon/GingerCoreCommon.csproj b/Ginger/GingerCoreCommon/GingerCoreCommon.csproj index 9f67a0b0ee..908d4b9dca 100644 --- a/Ginger/GingerCoreCommon/GingerCoreCommon.csproj +++ b/Ginger/GingerCoreCommon/GingerCoreCommon.csproj @@ -35,7 +35,7 @@ - + diff --git a/Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/ActVisualTesting.cs b/Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/ActVisualTesting.cs index b6a91cd0d9..c5150c6f88 100644 --- a/Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/ActVisualTesting.cs +++ b/Ginger/GingerCoreNET/ActionsLib/UI/VisualTesting/ActVisualTesting.cs @@ -25,6 +25,7 @@ limitations under the License. using GingerCore.Actions.VisualTesting; using GingerCore.Drivers; using GingerCoreNET.SolutionRepositoryLib.RepositoryObjectsLib.PlatformsLib; +using OpenQA.Selenium; using System; using System.Collections.Generic; using System.Drawing; @@ -395,7 +396,12 @@ public bool CheckSetAppWindowSize() break; case eChangeAppWindowSize.Custom: mDriver.ChangeAppWindowSize(Convert.ToInt32(GetInputParamCalculatedValue(nameof(SetAppWindowWidth))), Convert.ToInt32(GetInputParamCalculatedValue(nameof(SetAppWindowHeight)))); - Size size = mDriver.GetWebDriver().Manage().Window.Size; + IWebDriver webDriver = mDriver.GetWebDriver(); + if (webDriver == null) + { + return true; + } + Size size = webDriver.Manage().Window.Size; if (Convert.ToInt32(GetInputParamCalculatedValue(nameof(SetAppWindowWidth))) + 5 < size.Width)//+5 added to check with actual viewport/size of the browser which can be different by 2 0r 3 points { this.Error = string.Format("Unable to set custom width of web page to {0}, min supported width is {1}.", GetInputParamCalculatedValue(nameof(SetAppWindowWidth)), size.Width.ToString()); diff --git a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActAccessibilityTestingHandler.cs b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActAccessibilityTestingHandler.cs index 8db319073f..ac467164f9 100644 --- a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActAccessibilityTestingHandler.cs +++ b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/ActionHandlers/ActAccessibilityTestingHandler.cs @@ -93,18 +93,18 @@ private AxeRunOptions CreateAxeRunOptions() List sevritylist = _act.SeverityList.Select(x => x.Value.ToLower()).ToList(); 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()) + } + if (ExcludeRules != null && ExcludeRules.Any()) + { + var rulesMap = new Dictionary(); + foreach (var rule in ExcludeRules) { - var rulesMap = new Dictionary(); - foreach (var rule in ExcludeRules) + rulesMap[rule] = new RuleOptions { - rulesMap[rule] = new RuleOptions - { - Enabled = false - }; - } - axeRunOptions.Rules = rulesMap; + Enabled = false + }; } + axeRunOptions.Rules = rulesMap; } } diff --git a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs index 9c669ce597..efdbf7710d 100644 --- a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs +++ b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Playwright/PlaywrightDriver.cs @@ -223,6 +223,11 @@ public override void RunAction(Act act) } break; case ActAccessibilityTesting actAccessibilityTesting: + if (!BrowserPrivateMode) + { + act.Error = $"Playwright Driver must be in Private mode for using Accessibility actions"; + break; + } ActAccessibilityTestingHandler actAccessibilityTestingHandler; if (actAccessibilityTesting.GetAccessibilityTarget() == ActAccessibilityTesting.eTarget.Element) { @@ -257,7 +262,7 @@ public bool IsActionSupported(Act act, out string message) { message = string.Empty; - if (act is ActWithoutDriver or ActScreenShot) + if (act is ActWithoutDriver or ActScreenShot or ActGotoURL or ActAccessibilityTesting) { return true; } @@ -306,8 +311,12 @@ public bool IsActionSupported(Act act, out string message) } else if (act is ActVisualTesting actVisualTesting) { - message = $"{actVisualTesting.VisualTestingAnalyzer} is not supported by Playwright driver, use Selenium driver instead."; - return actVisualTesting.VisualTestingAnalyzer != ActVisualTesting.eVisualTestingAnalyzer.Applitools; + if (actVisualTesting.VisualTestingAnalyzer == ActVisualTesting.eVisualTestingAnalyzer.Applitools) + { + message = $"{actVisualTesting.VisualTestingAnalyzer} is not supported by Playwright driver, use Selenium driver instead."; + return false; + } + return true; } else { diff --git a/Ginger/GingerCoreNET/GingerCoreNET.csproj b/Ginger/GingerCoreNET/GingerCoreNET.csproj index 41ecf0044a..38fd7594da 100644 --- a/Ginger/GingerCoreNET/GingerCoreNET.csproj +++ b/Ginger/GingerCoreNET/GingerCoreNET.csproj @@ -284,7 +284,7 @@ - + diff --git a/Ginger/GingerCoreNET/LiteDBFolder/LiteDbConnector.cs b/Ginger/GingerCoreNET/LiteDBFolder/LiteDbConnector.cs index 919e302850..a2887a58b3 100644 --- a/Ginger/GingerCoreNET/LiteDBFolder/LiteDbConnector.cs +++ b/Ginger/GingerCoreNET/LiteDBFolder/LiteDbConnector.cs @@ -71,35 +71,41 @@ public ILiteCollection GetCollection(string collectionName) collection = db.GetCollection(collectionName); } } + catch(UnauthorizedAccessException ex) + { + Reporter.ToLog(eLogLevel.ERROR, $"Access denied while trying to get collection: {collectionName}", ex); + } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, $"Failed to Get Collection: {collectionName}", ex); - throw; } return collection; } -/* - * This function is not used anywhere - * public bool DeleteCollectionItems(LiteCollection baseColl, Query query) + + //This function is not used anywhere + //public bool DeleteCollectionItems(LiteCollection baseColl, Query query) + //{ + // bool result = false; + // try + // { + // using (var db = new LiteDatabase(this.ConnectionString)) + // { + // result = baseColl.Delete(query) > 0; + // } + // } + // catch (Exception ex) + // { + // Console.WriteLine("DeleteCollectionItems Error - " + ex.Message); + // } + // return result; + //} + + public bool DeleteDocumentByLiteDbRunSet(LiteDbRunSet liteDbRunSet, eExecutedFrom executedFrom = eExecutedFrom.Run) { - bool result = false; + bool result = true; try { - using (var db = new LiteDatabase(this.ConnectionString)) - { - result = baseColl.Delete(query) > 0; - } - } - catch (Exception ex) - { - Console.WriteLine("DeleteCollectionItems Error - " + ex.Message); - } - return result; - } -*/ public bool DeleteDocumentByLiteDbRunSet(LiteDbRunSet liteDbRunSet, eExecutedFrom executedFrom = eExecutedFrom.Run) - { - bool result = true; var runSetLiteColl = GetCollection(NameInDb()); var runnerssLiteColl = GetCollection(NameInDb()); foreach (LiteDbRunner ldbRunner in liteDbRunSet.RunnersColl) @@ -133,6 +139,12 @@ public ILiteCollection GetCollection(string collectionName) { runSetLiteColl.Delete(liteDbRunSet._id); } + } + catch (Exception ex) + { + Reporter.ToLog(eLogLevel.ERROR, $"Failed to delete document for RunSet: {liteDbRunSet._id}", ex); + result = false; + } return result; } public string NameInDb() @@ -158,7 +170,7 @@ public void SetCollection(ILiteCollection baseColl, List updateData) } catch (Exception ex) { - Console.WriteLine("SetCollection Error - " + ex.Message); + Reporter.ToLog(eLogLevel.ERROR, "An error occurred while attempting to insert data into LiteDB.", ex); } } @@ -173,7 +185,7 @@ public void SaveImage(string imagePath, string imageName) } catch (Exception ex) { - Console.WriteLine("SaveImage - " + ex.Message); + Reporter.ToLog(eLogLevel.ERROR, "An error occurred while attempting to save image.", ex); } } @@ -191,7 +203,7 @@ public void GetImage(string imagePath) } catch (Exception ex) { - Console.WriteLine("GetImage - " + ex.Message); + Reporter.ToLog(eLogLevel.ERROR, "An error occurred while attempting to get image.", ex); } } } diff --git a/Ginger/GingerCoreNET/Run/RunListenerLib/LiteDBRepository.cs b/Ginger/GingerCoreNET/Run/RunListenerLib/LiteDBRepository.cs index 7989f07943..786668aaa6 100644 --- a/Ginger/GingerCoreNET/Run/RunListenerLib/LiteDBRepository.cs +++ b/Ginger/GingerCoreNET/Run/RunListenerLib/LiteDBRepository.cs @@ -401,35 +401,42 @@ private void SetBfobjects(Context context, eExecutedFrom executedFrom) public override void SetReportRunner(GingerExecutionEngine gingerRunner, GingerReport gingerReport, ParentGingerData gingerData, Context mContext, string filename, int runnerCount) { - base.SetReportRunner(gingerRunner, gingerReport, gingerData, mContext, filename, runnerCount); - LiteDbRunner runner = new LiteDbRunner(); - runner.AllBusinessFlowsColl.AddRange(liteDbBFList); - if (lastRunnertStatus == eRunStatus.Stopped && gingerRunner.RunsetStatus != eRunStatus.Stopped && runner.BusinessFlowsColl.Count > gingerRunner.BusinessFlows.Count) + try { - runner.AllBusinessFlowsColl.RemoveRange(0, gingerRunner.BusinessFlows.Count); - } + base.SetReportRunner(gingerRunner, gingerReport, gingerData, mContext, filename, runnerCount); + LiteDbRunner runner = new LiteDbRunner(); + runner.AllBusinessFlowsColl.AddRange(liteDbBFList); + if (lastRunnertStatus == eRunStatus.Stopped && gingerRunner.RunsetStatus != eRunStatus.Stopped && runner.BusinessFlowsColl.Count > gingerRunner.BusinessFlows.Count) + { + runner.AllBusinessFlowsColl.RemoveRange(0, gingerRunner.BusinessFlows.Count); + } - SetRunnerChildCounts(runner, gingerRunner.BusinessFlows); + SetRunnerChildCounts(runner, gingerRunner.BusinessFlows); - runner.SetReportData(gingerReport); - SaveObjToReporsitory(runner, liteDbManager.NameInDb()); - if (ExecutionLoggerManager.RunSetReport == null) - { - ExecutionLoggerManager.RunSetReport = new RunSetReport(); - ExecutionLoggerManager.RunSetReport.GUID = Guid.NewGuid().ToString(); - } - if (lastRunnertStatus == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped) - { - var runnerItem = ExecutionLoggerManager.RunSetReport.liteDbRunnerList.Find(x => x.Name == runner.Name); - ExecutionLoggerManager.RunSetReport.liteDbRunnerList.Remove(runnerItem); + runner.SetReportData(gingerReport); + SaveObjToReporsitory(runner, liteDbManager.NameInDb()); + if (ExecutionLoggerManager.RunSetReport == null) + { + ExecutionLoggerManager.RunSetReport = new RunSetReport(); + ExecutionLoggerManager.RunSetReport.GUID = Guid.NewGuid().ToString(); + } + if (lastRunnertStatus == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped) + { + var runnerItem = ExecutionLoggerManager.RunSetReport.liteDbRunnerList.Find(x => x.Name == runner.Name); + ExecutionLoggerManager.RunSetReport.liteDbRunnerList.Remove(runnerItem); + } + if (runner.RunStatus != eRunStatus.Stopped.ToString()) + { + liteDbBFList.Clear(); + } + ExecutionLoggerManager.RunSetReport.liteDbRunnerList.Add(runner); + lastRunnertStatus = gingerRunner.RunsetStatus; + ClearSeq(); } - if (runner.RunStatus != eRunStatus.Stopped.ToString()) + catch (Exception ex) { - liteDbBFList.Clear(); + Reporter.ToLog(eLogLevel.ERROR, "An error occurred while attempting to set Report runner.", ex); } - ExecutionLoggerManager.RunSetReport.liteDbRunnerList.Add(runner); - lastRunnertStatus = gingerRunner.RunsetStatus; - ClearSeq(); } private void SetRunnerChildCounts(LiteDbRunner runner, ObservableList businessFlows) {