diff --git a/InteractiveAutomationToolkit/Dialogs/Dialog.cs b/InteractiveAutomationToolkit/Dialogs/Dialog.cs index 5bb2cfd..0af73a2 100644 --- a/InteractiveAutomationToolkit/Dialogs/Dialog.cs +++ b/InteractiveAutomationToolkit/Dialogs/Dialog.cs @@ -731,6 +731,8 @@ private void CheckIfVisibleWidgetOverlaps(Widget widget) private void CheckIfOtherWidgetsAreVisibleOnPosition(Widget widget, IWidgetLayout layout, int row, int column) { + var overlappingWidgets = new List(); + foreach (Widget otherWidget in widgetLayouts.Keys) { if (!otherWidget.IsVisible || widget.Equals(otherWidget)) @@ -741,9 +743,19 @@ private void CheckIfOtherWidgetsAreVisibleOnPosition(Widget widget, IWidgetLayou IWidgetLayout otherWidgetLayout = widgetLayouts[otherWidget]; if (column >= otherWidgetLayout.Column && column < otherWidgetLayout.Column + otherWidgetLayout.ColumnSpan && row >= otherWidgetLayout.Row && row < otherWidgetLayout.Row + otherWidgetLayout.RowSpan) { - throw new OverlappingWidgetsException(String.Format("The widget overlaps with another widget in the Dialog on Row {0}, Column {1}, RowSpan {2}, ColumnSpan {3}", layout.Row, layout.Column, layout.RowSpan, layout.ColumnSpan)); + overlappingWidgets.Add(otherWidget); } } + + if (overlappingWidgets.Count > 0) + { + string overlappingWidgetsInfo = String.Join(", ", overlappingWidgets.Select(w => FormatWidgetInfo(w, widgetLayouts[w]))); + + throw new OverlappingWidgetsException(String.Format( + "Widget {0} overlaps with: {1}", + FormatWidgetInfo(widget, layout), + overlappingWidgetsInfo)); + } } private string GetRowDefinitions(SortedSet rowsInUse) @@ -936,5 +948,14 @@ internal void RaiseResultEvents(IUIResults uir, ILogger logger = null) intractable.RaiseResultEvents(logger); } } + + private string FormatWidgetInfo(Widget widget, IWidgetLayout layout) + { + string debugTagPart = String.IsNullOrEmpty(widget.DebugTag) + ? String.Empty + : $" [DebugTag: '{widget.DebugTag}']"; + + return $"{widget.GetType().Name}{debugTagPart} (Row {layout.Row}, Column {layout.Column}, RowSpan {layout.RowSpan}, ColumnSpan {layout.ColumnSpan})"; + } } }