[Libreoffice-commits] core.git: sc/qa uitest/uitest

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 29 11:25:29 UTC 2021


 sc/qa/uitest/autofilter/autofilterBugs.py              |   26 
 sc/qa/uitest/autofilter/tdf117276_autofilter_reset.py  |    6 
 sc/qa/uitest/autofilter/tdf126306.py                   |    6 
 sc/qa/uitest/autofilter/tdf140754.py                   |   17 
 sc/qa/uitest/autofilter/tdf36383.py                    |   20 
 sc/qa/uitest/autofilter/tdf46062.py                    |    6 
 sc/qa/uitest/calc_tests/CellDropDownItems.py           |   41 -
 sc/qa/uitest/calc_tests/autofill.py                    |   78 --
 sc/qa/uitest/calc_tests/calcSheetDelete.py             |   54 -
 sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py |  319 ++++-----
 sc/qa/uitest/calc_tests/columns.py                     |  208 ++----
 sc/qa/uitest/calc_tests/formatCells.py                 |  572 +++++++----------
 sc/qa/uitest/calc_tests/mergedRowsColumns.py           |   62 -
 sc/qa/uitest/calc_tests/printRange.py                  |    6 
 sc/qa/uitest/calc_tests/rows.py                        |  142 +---
 sc/qa/uitest/calc_tests/sheetRename.py                 |   46 -
 sc/qa/uitest/calc_tests/zoom.py                        |   50 -
 sc/qa/uitest/calc_tests2/dataform.py                   |    6 
 sc/qa/uitest/calc_tests2/tdf114992.py                  |    6 
 sc/qa/uitest/calc_tests2/tdf117367.py                  |   45 -
 sc/qa/uitest/calc_tests2/tdf126577.py                  |   17 
 sc/qa/uitest/calc_tests2/tdf37623.py                   |    9 
 sc/qa/uitest/calc_tests2/tdf46138.py                   |    9 
 sc/qa/uitest/calc_tests2/tdf51700.py                   |   13 
 sc/qa/uitest/calc_tests3/clearCells.py                 |  340 ++++------
 sc/qa/uitest/calc_tests3/insertQrCodeGen.py            |   49 -
 sc/qa/uitest/calc_tests3/tdf57274.py                   |   16 
 sc/qa/uitest/calc_tests3/tdf62267.py                   |   25 
 sc/qa/uitest/calc_tests3/tdf63805.py                   |    6 
 sc/qa/uitest/calc_tests3/tdf65856.py                   |   18 
 sc/qa/uitest/calc_tests3/tdf69450.py                   |   28 
 sc/qa/uitest/calc_tests3/tdf69981.py                   |   44 -
 sc/qa/uitest/calc_tests3/tdf73006.py                   |   13 
 sc/qa/uitest/calc_tests3/tdf79983.py                   |   32 
 sc/qa/uitest/calc_tests3/tdf82398.py                   |   17 
 sc/qa/uitest/calc_tests4/tdf131170.py                  |   45 -
 sc/qa/uitest/calc_tests4/tdf85403.py                   |    7 
 sc/qa/uitest/calc_tests4/tdf85979.py                   |   13 
 sc/qa/uitest/calc_tests4/tdf86253.py                   |   38 -
 sc/qa/uitest/calc_tests4/tdf88999.py                   |   35 -
 sc/qa/uitest/calc_tests4/tdf89907.py                   |   17 
 sc/qa/uitest/calc_tests4/tdf92423.py                   |   34 -
 sc/qa/uitest/calc_tests4/textToColumns.py              |  388 +++++------
 sc/qa/uitest/calc_tests4/trackedChanges.py             |   22 
 sc/qa/uitest/calc_tests6/autoFormat.py                 |   82 +-
 sc/qa/uitest/calc_tests6/autocorrectOptions.py         |  153 ++--
 sc/qa/uitest/calc_tests6/hideShowSheet.py              |   30 
 sc/qa/uitest/calc_tests6/moveCopySheet.py              |   57 -
 sc/qa/uitest/calc_tests6/scenarios.py                  |   28 
 sc/qa/uitest/calc_tests6/shareSpreadsheet.py           |   13 
 sc/qa/uitest/calc_tests6/tdf104378.py                  |    7 
 sc/qa/uitest/calc_tests6/tdf107267.py                  |   69 --
 sc/qa/uitest/calc_tests6/tdf116996.py                  |   53 -
 sc/qa/uitest/calc_tests6/tdf118638.py                  |   35 -
 sc/qa/uitest/calc_tests6/tdf121263.py                  |   21 
 sc/qa/uitest/calc_tests6/tdf91726.py                   |   43 -
 sc/qa/uitest/calc_tests7/tdf106667.py                  |    6 
 sc/qa/uitest/calc_tests7/tdf122509.py                  |   41 -
 sc/qa/uitest/calc_tests7/tdf123122.py                  |   62 -
 sc/qa/uitest/calc_tests7/tdf124896.py                  |    7 
 sc/qa/uitest/calc_tests8/navigator.py                  |    9 
 sc/qa/uitest/calc_tests8/tdf114710.py                  |   21 
 sc/qa/uitest/calc_tests8/tdf118308.py                  |   33 
 sc/qa/uitest/calc_tests8/tdf125051.py                  |    7 
 sc/qa/uitest/calc_tests8/tdf137726.py                  |    7 
 sc/qa/uitest/calc_tests9/pivotTable.py                 |   53 -
 sc/qa/uitest/calc_tests9/tdf121949.py                  |    6 
 sc/qa/uitest/calc_tests9/tdf126673.py                  |   22 
 sc/qa/uitest/calc_tests9/tdf130371.py                  |   41 -
 sc/qa/uitest/calc_tests9/tdf133629.py                  |   29 
 sc/qa/uitest/calc_tests9/tdf137446.py                  |   34 -
 sc/qa/uitest/calc_tests9/tdf141244.py                  |   21 
 sc/qa/uitest/chart/copyPaste.py                        |   15 
 sc/qa/uitest/chart/create_chart.py                     |   54 -
 sc/qa/uitest/chart/edit_chart.py                       |    8 
 sc/qa/uitest/chart/tdf101894.py                        |   28 
 sc/qa/uitest/chart/tdf124295.py                        |   19 
 sc/qa/uitest/chart/tdf131715.py                        |   15 
 sc/qa/uitest/chart/tdf43175.py                         |   13 
 sc/qa/uitest/chart/tdf46885.py                         |   18 
 sc/qa/uitest/chart/tdf62349.py                         |    7 
 sc/qa/uitest/chart/tdf99069.py                         |   10 
 sc/qa/uitest/conditional_format/tdf100793.py           |   97 +-
 sc/qa/uitest/conditional_format/tdf104026.py           |   19 
 sc/qa/uitest/conditional_format/tdf105544.py           |   49 -
 sc/qa/uitest/conditional_format/tdf117899.py           |   26 
 sc/qa/uitest/conditional_format/tdf81696.py            |   11 
 sc/qa/uitest/conditional_format/tdf96453.py            |   57 -
 sc/qa/uitest/csv_dialog/tdf142395.py                   |    9 
 sc/qa/uitest/csv_dialog/tdf57841.py                    |    9 
 sc/qa/uitest/csv_dialog/tdf60468.py                    |    9 
 sc/qa/uitest/key_f4/f4.py                              |   42 -
 sc/qa/uitest/manual_tests/calc.py                      |   52 -
 sc/qa/uitest/manual_tests/more_calc.py                 |   13 
 sc/qa/uitest/options/tdf122977.py                      |   65 -
 sc/qa/uitest/pageFormat/tdf123508.py                   |   46 -
 sc/qa/uitest/protect/protectSheet.py                   |   40 -
 sc/qa/uitest/protect/protectSpreadsheet.py             |   22 
 sc/qa/uitest/range_name/create_range_name.py           |   66 -
 sc/qa/uitest/range_name/tdf137617.py                   |   68 --
 sc/qa/uitest/search_replace/tdf39917.py                |   76 --
 sc/qa/uitest/signatureLine/insertSignatureLine.py      |   71 --
 sc/qa/uitest/sort/naturalSort.py                       |   47 -
 sc/qa/uitest/sort/sorting.py                           |  118 +--
 sc/qa/uitest/sort/subtotals.py                         |  132 +--
 sc/qa/uitest/sort/tdf100517.py                         |   15 
 sc/qa/uitest/sort/tdf105301.py                         |   35 -
 sc/qa/uitest/sort/tdf126678.py                         |   15 
 sc/qa/uitest/sort/tdf49531.py                          |   35 -
 sc/qa/uitest/sort/tdf53482.py                          |   58 -
 sc/qa/uitest/sort/tdf54018.py                          |   17 
 sc/qa/uitest/sort/tdf57465.py                          |   23 
 sc/qa/uitest/sort/tdf91305.py                          |   32 
 sc/qa/uitest/sort/tdf95192.py                          |   13 
 sc/qa/uitest/sort/tdf99208.py                          |   41 -
 sc/qa/uitest/sort/tdf99627.py                          |   19 
 sc/qa/uitest/sort/tdf99773.py                          |   15 
 sc/qa/uitest/validity/tdf137945.py                     |   21 
 sc/qa/uitest/validity/tdf138134.py                     |   29 
 sc/qa/uitest/validity/tdf53920.py                      |   56 -
 sc/qa/uitest/validity/tdf65686.py                      |   42 -
 sc/qa/uitest/validity/tdf96698.py                      |  144 +---
 sc/qa/uitest/validity/validity.py                      |  150 +---
 uitest/uitest/test.py                                  |    3 
 124 files changed, 2598 insertions(+), 3437 deletions(-)

New commits:
commit 279ab35ad07a958b5b8d7d593b9817e7365b9bb5
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon Jun 28 16:52:26 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue Jun 29 13:24:54 2021 +0200

    uitest: guard execute_dialog_through_command in sc
    
    Mostly done with a script
    for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac
    < UITest: introduce guarded context managers >
    
    Change-Id: Id49eb66ba2827a6e2d0a737e48726a1d1c49c814
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118029
    Tested-by: Xisco Fauli <xiscofauli at libreoffice.org>
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sc/qa/uitest/autofilter/autofilterBugs.py b/sc/qa/uitest/autofilter/autofilterBugs.py
index 908d78aa62d3..5f344536da15 100644
--- a/sc/qa/uitest/autofilter/autofilterBugs.py
+++ b/sc/qa/uitest/autofilter/autofilterBugs.py
@@ -16,11 +16,9 @@ class autofilter(UITestCase):
             #autofilter exist
             self.assertEqual(calc_doc.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True)
 
-            self.ui_test.execute_dialog_through_command(".uno:DataSort")
-            xDialog = self.xUITest.getTopFocusWindow()
+            with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort", close_button="cancel"):
+                pass
 
-            xcancBtn = xDialog.getChild("cancel")
-            self.ui_test.close_dialog_through_button(xcancBtn)
             #autofilter still exist
             self.assertEqual(calc_doc.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True)
 
@@ -37,18 +35,15 @@ class autofilter(UITestCase):
         enter_text_to_cell(xGridWindow, "B3", "d")
         xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B1"}))
 
-        self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xYesBtn = xDialog.getChild("yes")
-        self.ui_test.close_dialog_through_button(xYesBtn)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:DataFilterAutoFilter", close_button="yes"):
+            pass
 
         xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A3"}))
         self.xUITest.executeCommand(".uno:SelectRow") #select two rows
 
-        self.ui_test.execute_dialog_through_command(".uno:DataSort")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort"):
+            pass
+
         #autofilter still exist
         self.assertEqual(document.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True)
 
@@ -64,10 +59,9 @@ class autofilter(UITestCase):
 
             xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:E6"}))
 
-            self.ui_test.execute_dialog_through_command(".uno:DataSort")
-            xDialog = self.xUITest.getTopFocusWindow()
-            xOKBtn = xDialog.getChild("ok")
-            self.ui_test.close_dialog_through_button(xOKBtn)
+            with self.ui_test.execute_dialog_through_command_guarded(".uno:DataSort"):
+                pass
+
             #autofilter still exist
             self.assertEqual(calc_doc.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True)
 
diff --git a/sc/qa/uitest/autofilter/tdf117276_autofilter_reset.py b/sc/qa/uitest/autofilter/tdf117276_autofilter_reset.py
index 89be1bb51099..ccfd0e36fe56 100644
--- a/sc/qa/uitest/autofilter/tdf117276_autofilter_reset.py
+++ b/sc/qa/uitest/autofilter/tdf117276_autofilter_reset.py
@@ -97,10 +97,8 @@ class tdf117276_autofilter_reset(UITestCase):
         xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B6"}))
 
         # 2. switch on auto-filter
-        self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xYesBtn = xDialog.getChild("yes")
-        self.ui_test.close_dialog_through_button(xYesBtn)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:DataFilterAutoFilter", close_button="yes"):
+            pass
 
         # autofilter still exist
         self.assertEqual(document.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True)
diff --git a/sc/qa/uitest/autofilter/tdf126306.py b/sc/qa/uitest/autofilter/tdf126306.py
index 73f8d83f8b85..08ca30974354 100644
--- a/sc/qa/uitest/autofilter/tdf126306.py
+++ b/sc/qa/uitest/autofilter/tdf126306.py
@@ -34,10 +34,8 @@ class tdf126306(UITestCase):
 
         xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A15"}))
 
-        self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xYesBtn = xDialog.getChild("yes")
-        self.ui_test.close_dialog_through_button(xYesBtn)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:DataFilterAutoFilter", close_button="yes"):
+            pass
 
         self.assertEqual(document.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True)
 
diff --git a/sc/qa/uitest/autofilter/tdf140754.py b/sc/qa/uitest/autofilter/tdf140754.py
index 67a4c5055eb7..bd488a7f80b4 100644
--- a/sc/qa/uitest/autofilter/tdf140754.py
+++ b/sc/qa/uitest/autofilter/tdf140754.py
@@ -16,19 +16,16 @@ class tdf140754(UITestCase):
         with self.ui_test.load_file(get_url_for_data_file("tdf140754.ods")) as calc_doc:
 
             #Make sure 'multi-threaded calculation' is enabled
-            self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog")
-            xDialogOpt = self.xUITest.getTopFocusWindow()
+            with self.ui_test.execute_dialog_through_command_guarded(".uno:OptionsTreeDialog") as xDialogOpt:
 
-            xPages = xDialogOpt.getChild("pages")
-            xCalcEntry = xPages.getChild('3')
-            xCalcEntry.executeAction("EXPAND", tuple())
-            xCalcCalculateEntry = xCalcEntry.getChild('3')
-            xCalcCalculateEntry.executeAction("SELECT", tuple())
+                xPages = xDialogOpt.getChild("pages")
+                xCalcEntry = xPages.getChild('3')
+                xCalcEntry.executeAction("EXPAND", tuple())
+                xCalcCalculateEntry = xCalcEntry.getChild('3')
+                xCalcCalculateEntry.executeAction("SELECT", tuple())
 
-            self.assertEqual('true', get_state_as_dict(xDialogOpt.getChild('threadingenabled'))["Selected"])
+                self.assertEqual('true', get_state_as_dict(xDialogOpt.getChild('threadingenabled'))["Selected"])
 
-            xOKBtn = xDialogOpt.getChild("ok")
-            self.ui_test.close_dialog_through_button(xOKBtn)
 
 
             self.assertEqual(0, get_cell_by_position(calc_doc, 0, 0, 30).getValue())
diff --git a/sc/qa/uitest/autofilter/tdf36383.py b/sc/qa/uitest/autofilter/tdf36383.py
index d55db21837b3..46bc1c915317 100644
--- a/sc/qa/uitest/autofilter/tdf36383.py
+++ b/sc/qa/uitest/autofilter/tdf36383.py
@@ -42,24 +42,18 @@ class tdf36383(UITestCase):
         self.assertFalse(row.getPropertyValue("IsVisible"))
 
         #row height
-        self.ui_test.execute_dialog_through_command(".uno:RowHeight")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
-        xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:RowHeight") as xDialog:
+            xvalue = xDialog.getChild("value")
+            xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+            xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+            xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
 
-        xOk = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOk)
 
         self.assertFalse(row.getPropertyValue("IsVisible"))
 
         #optimal row height
-        self.ui_test.execute_dialog_through_command(".uno:SetOptimalRowHeight")
-        xDialog = self.xUITest.getTopFocusWindow()
-
-        xOk = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOk)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:SetOptimalRowHeight"):
+            pass
 
         self.assertFalse(row.getPropertyValue("IsVisible"))
 
diff --git a/sc/qa/uitest/autofilter/tdf46062.py b/sc/qa/uitest/autofilter/tdf46062.py
index 41b42eb0e475..bc941ef0fccc 100644
--- a/sc/qa/uitest/autofilter/tdf46062.py
+++ b/sc/qa/uitest/autofilter/tdf46062.py
@@ -24,10 +24,8 @@ class tdf46062(UITestCase):
 
         gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"}))
 
-        self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xYesBtn = xDialog.getChild("yes")
-        self.ui_test.close_dialog_through_button(xYesBtn)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:DataFilterAutoFilter", close_button="yes"):
+            pass
 
         gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
         xFloatWindow = self.xUITest.getFloatWindow()
diff --git a/sc/qa/uitest/calc_tests/CellDropDownItems.py b/sc/qa/uitest/calc_tests/CellDropDownItems.py
index 7b089751cff5..def8a81a515a 100644
--- a/sc/qa/uitest/calc_tests/CellDropDownItems.py
+++ b/sc/qa/uitest/calc_tests/CellDropDownItems.py
@@ -22,28 +22,25 @@ class CellDropDownItems(UITestCase):
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C10"}))
 
         #Open Validation Dialog
-        self.ui_test.execute_dialog_through_command(".uno:Validation")
-        xDialog = self.xUITest.getTopFocusWindow()
-
-        #Select List option
-        xallow = xDialog.getChild("allow")
-        xallow.executeAction("SELECT", mkPropertyValues({"POS": "6"}))
-
-        #Add items to the List
-        xminlist = xDialog.getChild("minlist")
-        xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item1"}))
-        xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
-        xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item2"}))
-        xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
-        xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item3"}))
-        xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
-        xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item4"}))
-        xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
-        xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item5"}))
-
-        #Close the dialog
-        xOk = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOk)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:Validation") as xDialog:
+
+            #Select List option
+            xallow = xDialog.getChild("allow")
+            xallow.executeAction("SELECT", mkPropertyValues({"POS": "6"}))
+
+            #Add items to the List
+            xminlist = xDialog.getChild("minlist")
+            xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item1"}))
+            xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+            xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item2"}))
+            xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+            xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item3"}))
+            xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+            xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item4"}))
+            xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+            xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item5"}))
+
+            #Close the dialog
 
         #Launch the Select Menu to view the list ans select first item in the list
         gridwin = xCalcDoc.getChild("grid_window")
diff --git a/sc/qa/uitest/calc_tests/autofill.py b/sc/qa/uitest/calc_tests/autofill.py
index 60a5f04f3315..ee0d549fee7b 100644
--- a/sc/qa/uitest/calc_tests/autofill.py
+++ b/sc/qa/uitest/calc_tests/autofill.py
@@ -19,10 +19,8 @@ class CalcAutofill(UITestCase):
             gridwin = xCalcDoc.getChild("grid_window")
             #Select cell A12 and drag the fill handle in the bottom right corner of the cell down to A18
             gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A12:A18"}))
-            self.ui_test.execute_dialog_through_command(".uno:FillSeries")
-            xDialog = self.xUITest.getTopFocusWindow()
-            xOK = xDialog.getChild("ok")
-            self.ui_test.close_dialog_through_button(xOK)
+            with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries"):
+                pass
             #Compare with the content in the right next column
             self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 11).getValue(), 18.34)
             self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 12).getValue(), 19.34)
@@ -33,16 +31,13 @@ class CalcAutofill(UITestCase):
             self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 17).getValue(), 24.34)
             #Select cell A12 and drag the fill handle in the bottom right corner of the cell up to A6
             gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A6:A12"}))
-            self.ui_test.execute_dialog_through_command(".uno:FillSeries")
-            xDialog = self.xUITest.getTopFocusWindow()
-            xup = xDialog.getChild("up")
-            xincrement = xDialog.getChild("increment")
-            xup.executeAction("CLICK", tuple())
-            xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-            xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
-            xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"}))
-            xOK = xDialog.getChild("ok")
-            self.ui_test.close_dialog_through_button(xOK)
+            with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries") as xDialog:
+                xup = xDialog.getChild("up")
+                xincrement = xDialog.getChild("increment")
+                xup.executeAction("CLICK", tuple())
+                xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+                xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+                xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"}))
             #Compare with the content in the right next column
             self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 5).getValue(), 12.34)
             self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 6).getValue(), 13.34)
@@ -54,10 +49,8 @@ class CalcAutofill(UITestCase):
 
             #Continue with the next cells with grey background
             gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "M12:M18"}))
-            self.ui_test.execute_dialog_through_command(".uno:FillSeries")
-            xDialog = self.xUITest.getTopFocusWindow()
-            xOK = xDialog.getChild("ok")
-            self.ui_test.close_dialog_through_button(xOK)
+            with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries"):
+                pass
             #Compare with the content in the right next column
             self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 11).getString(), "12abc40")
             self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 12).getString(), "12abc41")
@@ -68,16 +61,13 @@ class CalcAutofill(UITestCase):
             self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 17).getString(), "12abc46")
 
             gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "M6:M12"}))
-            self.ui_test.execute_dialog_through_command(".uno:FillSeries")
-            xDialog = self.xUITest.getTopFocusWindow()
-            xup = xDialog.getChild("up")
-            xincrement = xDialog.getChild("increment")
-            xup.executeAction("CLICK", tuple())
-            xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-            xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
-            xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"}))
-            xOK = xDialog.getChild("ok")
-            self.ui_test.close_dialog_through_button(xOK)
+            with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries") as xDialog:
+                xup = xDialog.getChild("up")
+                xincrement = xDialog.getChild("increment")
+                xup.executeAction("CLICK", tuple())
+                xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+                xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+                xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"}))
             #Compare with the content in the right next column
             self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 5).getString(), "12abc34")
             self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 6).getString(), "12abc35")
@@ -88,10 +78,8 @@ class CalcAutofill(UITestCase):
             self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 11).getString(), "12abc40")
 
             gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "P12:P18"}))
-            self.ui_test.execute_dialog_through_command(".uno:FillSeries")
-            xDialog = self.xUITest.getTopFocusWindow()
-            xOK = xDialog.getChild("ok")
-            self.ui_test.close_dialog_through_button(xOK)
+            with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries"):
+                pass
             #Compare with the content in the right next column
             self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 11).getString(), "10.64.127.7")
             self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 12).getString(), "10.64.127.8")
@@ -102,16 +90,13 @@ class CalcAutofill(UITestCase):
             self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 17).getString(), "10.64.127.13")
 
             gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "P6:P12"}))
-            self.ui_test.execute_dialog_through_command(".uno:FillSeries")
-            xDialog = self.xUITest.getTopFocusWindow()
-            xup = xDialog.getChild("up")
-            xincrement = xDialog.getChild("increment")
-            xup.executeAction("CLICK", tuple())
-            xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-            xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
-            xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"}))
-            xOK = xDialog.getChild("ok")
-            self.ui_test.close_dialog_through_button(xOK)
+            with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries") as xDialog:
+                xup = xDialog.getChild("up")
+                xincrement = xDialog.getChild("increment")
+                xup.executeAction("CLICK", tuple())
+                xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+                xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+                xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"}))
             #Compare with the content in the right next column
             self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 5).getString(), "10.64.127.1")
             self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 6).getString(), "10.64.127.2")
@@ -129,12 +114,9 @@ class CalcAutofill(UITestCase):
         enter_text_to_cell(gridwin, "A1", "1st")
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"}))
         gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"}))
-        self.ui_test.execute_dialog_through_command(".uno:FillSeries")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xautofill = xDialog.getChild("autofill")
-        xautofill.executeAction("CLICK", tuple())
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FillSeries") as xDialog:
+            xautofill = xDialog.getChild("autofill")
+            xautofill.executeAction("CLICK", tuple())
         self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1st")
         self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "2nd")
         self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "3rd")
diff --git a/sc/qa/uitest/calc_tests/calcSheetDelete.py b/sc/qa/uitest/calc_tests/calcSheetDelete.py
index b237003b648d..b52dc67e3dae 100644
--- a/sc/qa/uitest/calc_tests/calcSheetDelete.py
+++ b/sc/qa/uitest/calc_tests/calcSheetDelete.py
@@ -22,17 +22,13 @@ class calcSheetDelete(UITestCase):
         xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "L12"}))
         nrSheets = document.Sheets.getCount()  #default number
 
-        self.ui_test.execute_dialog_through_command(".uno:Insert")  #insert sheet
-        xDialog = self.xUITest.getTopFocusWindow()
-        xOKButton = xDialog.getChild("ok")
-        xOKButton.executeAction("CLICK", tuple())
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"):
+            pass
 
         self.assertEqual(document.Sheets.getCount(), nrSheets + 1)
 
-        self.ui_test.execute_dialog_through_command(".uno:Remove")  #delete sheet
-        xDialog = self.xUITest.getTopFocusWindow()
-        xOKButton = xDialog.getChild("yes")
-        xOKButton.executeAction("CLICK", tuple())
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:Remove", close_button="yes"):
+            pass
         xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
         xToolkit.processEventsToIdle()
 
@@ -51,15 +47,11 @@ class calcSheetDelete(UITestCase):
 
         nrSheets = document.Sheets.getCount()  #default number of sheets
 
-        self.ui_test.execute_dialog_through_command(".uno:Insert")  #insert sheet
-        xDialog = self.xUITest.getTopFocusWindow()
-        xOKButton = xDialog.getChild("ok")
-        xOKButton.executeAction("CLICK", tuple())
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"):
+            pass
 
-        self.ui_test.execute_dialog_through_command(".uno:Insert")  #insert sheet
-        xDialog = self.xUITest.getTopFocusWindow()
-        xOKButton = xDialog.getChild("ok")
-        xOKButton.executeAction("CLICK", tuple())
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"):
+            pass
         xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
         xToolkit.processEventsToIdle()
 
@@ -68,10 +60,8 @@ class calcSheetDelete(UITestCase):
         xGridWindow = xCalcDoc.getChild("grid_window")
         enter_text_to_cell(xGridWindow, "B2", "abcd")
 
-        self.ui_test.execute_dialog_through_command(".uno:Remove")  #delete sheet
-        xDialog = self.xUITest.getTopFocusWindow()
-        xOKButton = xDialog.getChild("yes")
-        xOKButton.executeAction("CLICK", tuple())
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:Remove", close_button="yes"):
+            pass
 
         self.assertEqual(document.Sheets.getCount(), nrSheets + 1)
         self.xUITest.executeCommand(".uno:Undo")
@@ -91,10 +81,8 @@ class calcSheetDelete(UITestCase):
         nrSheets = document.Sheets.getCount()  #default number
         i = 0
         while i < 6:
-            self.ui_test.execute_dialog_through_command(".uno:Insert")  #insert sheet
-            xDialog = self.xUITest.getTopFocusWindow()
-            xOKButton = xDialog.getChild("ok")
-            xOKButton.executeAction("CLICK", tuple())
+            with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"):
+                pass
             i = i + 1
         self.assertEqual(document.Sheets.getCount(), nrSheets + 6)
 
@@ -103,10 +91,8 @@ class calcSheetDelete(UITestCase):
             self.xUITest.executeCommand(".uno:JumpToNextTableSel")  #select next sheet
             i = i + 1
 
-        self.ui_test.execute_dialog_through_command(".uno:Remove")  #delete selected sheets
-        xDialog = self.xUITest.getTopFocusWindow()
-        xOKButton = xDialog.getChild("yes")
-        xOKButton.executeAction("CLICK", tuple())
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:Remove", close_button="yes"):
+            pass
 
         xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
         xToolkit.processEventsToIdle()
@@ -128,10 +114,8 @@ class calcSheetDelete(UITestCase):
         nrSheets = document.Sheets.getCount()  #default number
         i = 0
         while i < 100:
-            self.ui_test.execute_dialog_through_command(".uno:Insert")  #insert sheet
-            xDialog = self.xUITest.getTopFocusWindow()
-            xOKButton = xDialog.getChild("ok")
-            xOKButton.executeAction("CLICK", tuple())
+            with self.ui_test.execute_dialog_through_command_guarded(".uno:Insert"):
+                pass
             i = i + 1
         xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
         xToolkit.processEventsToIdle()
@@ -142,10 +126,8 @@ class calcSheetDelete(UITestCase):
             self.xUITest.executeCommand(".uno:JumpToNextTableSel")  #select next sheet
             i = i + 1
 
-        self.ui_test.execute_dialog_through_command(".uno:Remove")  #delete selected sheets
-        xDialog = self.xUITest.getTopFocusWindow()
-        xOKButton = xDialog.getChild("yes")
-        xOKButton.executeAction("CLICK", tuple())
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:Remove", close_button="yes"):
+            pass
 
         self.assertEqual(document.Sheets.getCount(), nrSheets)
         self.xUITest.executeCommand(".uno:Undo")
diff --git a/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py b/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py
index 7d4c2ff089ba..e41871b135b2 100644
--- a/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py
+++ b/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py
@@ -22,122 +22,119 @@ class CalcCellBackgroundColorSelector(UITestCase):
         #select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "6")  #tab Numbers
-        # click on color btn
-        xbtncolor = xDialog.getChild("btncolor")
-        xbtncolor.executeAction("CLICK",tuple())
-        xpaletteselector = xDialog.getChild("paletteselector")
-
-        # Now we have the ColorPage that we can get the color selector from it
-        xColorpage = xDialog.getChild("ColorPage")
-        color_selector = xColorpage.getChild("colorset")
-
-        # For chart-palettes colors
-        select_by_text(xpaletteselector, "chart-palettes")
-        # Select Color with id 2
-        color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "2"}))
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "2")
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "1")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "12")
-        self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 2")
-        self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(255,66,14)")
-
-        # Select Color with id 5
-        color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "5"}))
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "5")
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "4")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 5")
-        self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(126,0,33)")
-
-        # For libreoffice colors
-        select_by_text(xpaletteselector, "libreoffice")
-        # Select Color with id 6
-        color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "6"}))
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "6")
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "5")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "32")
-        self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Green Accent")
-        self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(44,238,14)")
-
-        # Select Color with id 30
-        color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "30"}))
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "30")
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "29")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Yellow Accent")
-        self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(255,215,76)")
-
-        # For html colors
-        select_by_text(xpaletteselector, "html")
-        # Select Color with id 1
-        color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"}))
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "1")
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "0")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "139")
-        self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "White")
-        # Select Color with id 120
-        color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "120"}))
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "120")
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "119")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Navy")
-
-        # For freecolour-hlc colors
-        select_by_text(xpaletteselector, "freecolour-hlc")
-        # Select Color with id 988
-        color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "988"}))
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "988")
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "987")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "1032")
-        self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "HLC 350 60 10")
-        # Select Color with id 575
-        color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "575"}))
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "575")
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "574")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "HLC 190 50 20")
-
-        # For tonal colors
-        select_by_text(xpaletteselector, "tonal")
-        # Select Color with id 17
-        color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "17"}))
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "17")
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "16")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "120")
-        self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Cyan 82%")
-        # Select Color with id 13
-        color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "13"}))
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "13")
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "12")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Magenta 82%")
-
-        # For material colors
-        select_by_text(xpaletteselector, "material")
-        # Select Color with id 9
-        color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "9"}))
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "9")
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "8")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "228")
-        self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Gray 800")
-
-        # For standard colors
-        select_by_text(xpaletteselector, "standard")
-        # Select Color with id 3
-        color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "3"}))
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "3")
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "2")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "120")
-        self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Dark Gray 3")
-
-        xOk = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOk)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "6")  #tab Numbers
+            # click on color btn
+            xbtncolor = xDialog.getChild("btncolor")
+            xbtncolor.executeAction("CLICK",tuple())
+            xpaletteselector = xDialog.getChild("paletteselector")
+
+            # Now we have the ColorPage that we can get the color selector from it
+            xColorpage = xDialog.getChild("ColorPage")
+            color_selector = xColorpage.getChild("colorset")
+
+            # For chart-palettes colors
+            select_by_text(xpaletteselector, "chart-palettes")
+            # Select Color with id 2
+            color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "2"}))
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "2")
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "1")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "12")
+            self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 2")
+            self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(255,66,14)")
+
+            # Select Color with id 5
+            color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "5"}))
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "5")
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "4")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 5")
+            self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(126,0,33)")
+
+            # For libreoffice colors
+            select_by_text(xpaletteselector, "libreoffice")
+            # Select Color with id 6
+            color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "6"}))
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "6")
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "5")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "32")
+            self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Green Accent")
+            self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(44,238,14)")
+
+            # Select Color with id 30
+            color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "30"}))
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "30")
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "29")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Yellow Accent")
+            self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(255,215,76)")
+
+            # For html colors
+            select_by_text(xpaletteselector, "html")
+            # Select Color with id 1
+            color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"}))
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "1")
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "0")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "139")
+            self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "White")
+            # Select Color with id 120
+            color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "120"}))
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "120")
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "119")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Navy")
+
+            # For freecolour-hlc colors
+            select_by_text(xpaletteselector, "freecolour-hlc")
+            # Select Color with id 988
+            color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "988"}))
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "988")
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "987")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "1032")
+            self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "HLC 350 60 10")
+            # Select Color with id 575
+            color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "575"}))
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "575")
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "574")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "HLC 190 50 20")
+
+            # For tonal colors
+            select_by_text(xpaletteselector, "tonal")
+            # Select Color with id 17
+            color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "17"}))
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "17")
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "16")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "120")
+            self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Cyan 82%")
+            # Select Color with id 13
+            color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "13"}))
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "13")
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "12")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Magenta 82%")
+
+            # For material colors
+            select_by_text(xpaletteselector, "material")
+            # Select Color with id 9
+            color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "9"}))
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "9")
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "8")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "228")
+            self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Gray 800")
+
+            # For standard colors
+            select_by_text(xpaletteselector, "standard")
+            # Select Color with id 3
+            color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "3"}))
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "3")
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "2")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "120")
+            self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Dark Gray 3")
+
 
         self.ui_test.close_doc()
 
@@ -151,58 +148,52 @@ class CalcCellBackgroundColorSelector(UITestCase):
         #select cell A5
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A5"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "6")  #tab Numbers
-        # click on color btn
-        xbtncolor = xDialog.getChild("btncolor")
-        xbtncolor.executeAction("CLICK",tuple())
-
-        # we will select color for cell A5 to be able to predict the latest color in
-        # recent color selector
-        xpaletteselector = xDialog.getChild("paletteselector")
-        xColorpage = xDialog.getChild("ColorPage")
-        color_selector = xColorpage.getChild("colorset")
-
-        # For chart-palettes colors
-        select_by_text(xpaletteselector, "chart-palettes")
-        # Select Color with id 2
-        color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "2"}))
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "2")
-        self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "1")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "12")
-        self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
-        self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 2")
-        xrgb = get_state_as_dict(color_selector)["RGB"]
-
-        # close the dialog after selection of the color
-        xOk = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOk)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "6")  #tab Numbers
+            # click on color btn
+            xbtncolor = xDialog.getChild("btncolor")
+            xbtncolor.executeAction("CLICK",tuple())
+
+            # we will select color for cell A5 to be able to predict the latest color in
+            # recent color selector
+            xpaletteselector = xDialog.getChild("paletteselector")
+            xColorpage = xDialog.getChild("ColorPage")
+            color_selector = xColorpage.getChild("colorset")
+
+            # For chart-palettes colors
+            select_by_text(xpaletteselector, "chart-palettes")
+            # Select Color with id 2
+            color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "2"}))
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "2")
+            self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "1")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "12")
+            self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12")
+            self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 2")
+            xrgb = get_state_as_dict(color_selector)["RGB"]
+
+            # close the dialog after selection of the color
 
         #select cell D3
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D3"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "6")  #tab Numbers
-        # click on color btn
-        xbtncolor = xDialog.getChild("btncolor")
-        xbtncolor.executeAction("CLICK",tuple())
-
-        xColorpage = xDialog.getChild("ColorPage")
-        recent_color_selector = xColorpage.getChild("recentcolorset")
-
-        # Select Color with id 1
-        recent_color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"}))
-        self.assertEqual(get_state_as_dict(recent_color_selector)["CurrColorId"], "1")
-        self.assertEqual(get_state_as_dict(recent_color_selector)["CurrColorPos"], "0")
-        self.assertEqual(get_state_as_dict(recent_color_selector)["ColorText"], "Chart 2")
-        self.assertEqual(get_state_as_dict(recent_color_selector)["RGB"], xrgb)
-
-        xOk = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOk)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "6")  #tab Numbers
+            # click on color btn
+            xbtncolor = xDialog.getChild("btncolor")
+            xbtncolor.executeAction("CLICK",tuple())
+
+            xColorpage = xDialog.getChild("ColorPage")
+            recent_color_selector = xColorpage.getChild("recentcolorset")
+
+            # Select Color with id 1
+            recent_color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"}))
+            self.assertEqual(get_state_as_dict(recent_color_selector)["CurrColorId"], "1")
+            self.assertEqual(get_state_as_dict(recent_color_selector)["CurrColorPos"], "0")
+            self.assertEqual(get_state_as_dict(recent_color_selector)["ColorText"], "Chart 2")
+            self.assertEqual(get_state_as_dict(recent_color_selector)["RGB"], xrgb)
+
 
         self.ui_test.close_doc()
 
diff --git a/sc/qa/uitest/calc_tests/columns.py b/sc/qa/uitest/calc_tests/columns.py
index 28649d07f3c2..ff1afd948caf 100644
--- a/sc/qa/uitest/calc_tests/columns.py
+++ b/sc/qa/uitest/calc_tests/columns.py
@@ -21,34 +21,28 @@ class CalcColumns(UITestCase):
         #select A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #column width
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        xdefault = xDialog.getChild("default")
-        self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true")  #default selected
-        heightStrOrig = get_state_as_dict(xvalue)["Text"]
-        heightVal = heightStrOrig[:4]  #default 2.26 cm
-        xvalue.executeAction("UP", tuple())  #2.36 cm
-        heightStr = get_state_as_dict(xvalue)["Text"]
-        heightValNew = heightStr[:4]
-        self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false")  #default not selected
-        self.assertEqual(heightValNew > heightVal, True)  #new value is bigger
-        xdefault.executeAction("CLICK", tuple())  #click default
-        self.assertEqual(get_state_as_dict(xvalue)["Text"] == heightStrOrig, True)  #default value set
-        #write your own value
-        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
-        xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
-        # Click Ok
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            xdefault = xDialog.getChild("default")
+            self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true")  #default selected
+            heightStrOrig = get_state_as_dict(xvalue)["Text"]
+            heightVal = heightStrOrig[:4]  #default 2.26 cm
+            xvalue.executeAction("UP", tuple())  #2.36 cm
+            heightStr = get_state_as_dict(xvalue)["Text"]
+            heightValNew = heightStr[:4]
+            self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false")  #default not selected
+            self.assertEqual(heightValNew > heightVal, True)  #new value is bigger
+            xdefault.executeAction("CLICK", tuple())  #click default
+            self.assertEqual(get_state_as_dict(xvalue)["Text"] == heightStrOrig, True)  #default value set
+            #write your own value
+            xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+            xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+            xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
+            # Click Ok
         #verify
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm")
-        xCancel = xDialog.getChild("cancel")
-        self.ui_test.close_dialog_through_button(xCancel)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth", close_button="cancel") as xDialog:
+            xvalue = xDialog.getChild("value")
+            self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm")
 
         self.ui_test.close_doc()
 
@@ -63,33 +57,24 @@ class CalcColumns(UITestCase):
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1", "EXTEND":"1"}))
 
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        xdefault = xDialog.getChild("default")
-        #write your own value
-        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
-        xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
-        # Click Ok
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            xdefault = xDialog.getChild("default")
+            #write your own value
+            xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+            xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+            xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
+            # Click Ok
         #verify
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm")
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm")
 
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"}))
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm")
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm")
 
         self.ui_test.close_doc()
 
@@ -104,15 +89,12 @@ class CalcColumns(UITestCase):
         #select A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #column width
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
-        xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
-        # Click Ok
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+            xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+            xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
+            # Click Ok
         #select column 1
         self.xUITest.executeCommand(".uno:SelectColumn")
         #copy
@@ -123,12 +105,9 @@ class CalcColumns(UITestCase):
         self.xUITest.executeCommand(".uno:Paste")
         #verify
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"}))
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm")
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm")
 
         self.ui_test.close_doc()
 
@@ -193,39 +172,30 @@ class CalcColumns(UITestCase):
         #select C1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"}))
         #column width
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
-        xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
-        # Click Ok
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+            xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+            xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
+            # Click Ok
         #select D1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"}))
         #column width
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
-        xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"2 cm"}))
-        # Click Ok
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+            xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+            xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"2 cm"}))
+            # Click Ok
         #select E1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"}))
         #column width
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
-        xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"3 cm"}))
-        # Click Ok
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+            xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+            xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"3 cm"}))
+            # Click Ok
         #select columns C-E
         gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:E1"}))
         self.xUITest.executeCommand(".uno:SelectColumn")
@@ -233,52 +203,34 @@ class CalcColumns(UITestCase):
         self.xUITest.executeCommand(".uno:InsertColumnsBefore")
         #verify
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"}))
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm")
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm")
 
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"}))
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.0003 cm")
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.0003 cm")
 
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"}))
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.0004 cm")
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.0004 cm")
 
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "F1"}))
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm")
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm")
 
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "G1"}))
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.0003 cm")
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.0003 cm")
 
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "H1"}))
-        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xvalue = xDialog.getChild("value")
-        self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.0004 cm")
-        xOK = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOK)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:ColumnWidth") as xDialog:
+            xvalue = xDialog.getChild("value")
+            self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.0004 cm")
 
         self.ui_test.close_doc()
 
diff --git a/sc/qa/uitest/calc_tests/formatCells.py b/sc/qa/uitest/calc_tests/formatCells.py
index f8b5cfd7c30c..4d4df4ac8f26 100644
--- a/sc/qa/uitest/calc_tests/formatCells.py
+++ b/sc/qa/uitest/calc_tests/formatCells.py
@@ -21,55 +21,49 @@ class formatCell(UITestCase):
         #select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "0")  #tab Numbers
-        xliststore1 = xDialog.getChild("categorylb")  #1st list / Category
-        xliststore2 = xDialog.getChild("formatlb")  #2nd list / Format
-        xdecimalsed = xDialog.getChild("decimalsed")
-        xleadzerosed = xDialog.getChild("leadzerosed")
-        xnegnumred = xDialog.getChild("negnumred")
-        xthousands = xDialog.getChild("thousands")
-        xlanguagelb = xDialog.getChild("languagelb")
-        xformatted = xDialog.getChild("formatted")
-        #language
-        select_by_text(xlanguagelb, "English (USA)")
-        #other properties
-        xdecimalsed.executeAction("UP", tuple())
-        xleadzerosed.executeAction("UP", tuple())
-        xnegnumred.executeAction("CLICK", tuple())
-        xthousands.executeAction("CLICK", tuple())
-        #format   #,#00.0;[RED]-#,#00.0
-        self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0")
-        #save
-        xOk = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOk)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "0")  #tab Numbers
+            xliststore1 = xDialog.getChild("categorylb")  #1st list / Category
+            xliststore2 = xDialog.getChild("formatlb")  #2nd list / Format
+            xdecimalsed = xDialog.getChild("decimalsed")
+            xleadzerosed = xDialog.getChild("leadzerosed")
+            xnegnumred = xDialog.getChild("negnumred")
+            xthousands = xDialog.getChild("thousands")
+            xlanguagelb = xDialog.getChild("languagelb")
+            xformatted = xDialog.getChild("formatted")
+            #language
+            select_by_text(xlanguagelb, "English (USA)")
+            #other properties
+            xdecimalsed.executeAction("UP", tuple())
+            xleadzerosed.executeAction("UP", tuple())
+            xnegnumred.executeAction("CLICK", tuple())
+            xthousands.executeAction("CLICK", tuple())
+            #format   #,#00.0;[RED]-#,#00.0
+            self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0")
+            #save
         #verify
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "0")  #tab Numbers
-        xliststore1 = xDialog.getChild("categorylb")  #1st list / Category
-        xliststore2 = xDialog.getChild("formatlb")  #2nd list / Format
-        xdecimalsed = xDialog.getChild("decimalsed")
-        xleadzerosed = xDialog.getChild("leadzerosed")
-        xnegnumred = xDialog.getChild("negnumred")
-        xthousands = xDialog.getChild("thousands")
-        xlanguagelb = xDialog.getChild("languagelb")
-        xformatted = xDialog.getChild("formatted")
-
-        self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Number")
-        self.assertEqual(get_state_as_dict(xlanguagelb)["SelectEntryText"], "English (USA)")
-        self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "1")
-        self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "2")
-        self.assertEqual(get_state_as_dict(xnegnumred)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(xthousands)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0")
-        xOk = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOk)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "0")  #tab Numbers
+            xliststore1 = xDialog.getChild("categorylb")  #1st list / Category
+            xliststore2 = xDialog.getChild("formatlb")  #2nd list / Format
+            xdecimalsed = xDialog.getChild("decimalsed")
+            xleadzerosed = xDialog.getChild("leadzerosed")
+            xnegnumred = xDialog.getChild("negnumred")
+            xthousands = xDialog.getChild("thousands")
+            xlanguagelb = xDialog.getChild("languagelb")
+            xformatted = xDialog.getChild("formatted")
+
+            self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Number")
+            self.assertEqual(get_state_as_dict(xlanguagelb)["SelectEntryText"], "English (USA)")
+            self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "1")
+            self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "2")
+            self.assertEqual(get_state_as_dict(xnegnumred)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(xthousands)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0")
 
         self.ui_test.close_doc()
 
@@ -82,52 +76,46 @@ class formatCell(UITestCase):
         #select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "1")  #tab Font
-        xSizeFont = xDialog.getChild("westsizelb-cjk")
-        xSizeFontEast = xDialog.getChild("eastsizelb")
-        xSizeFontCTL = xDialog.getChild("ctlsizelb")
-        xLangFont = xDialog.getChild("westlanglb-cjk")
-        xLangFontEast = xDialog.getChild("eastlanglb")
-        xLangFontCTL = xDialog.getChild("ctllanglb")
-
-        xSizeFont.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-        xSizeFont.executeAction("TYPE", mkPropertyValues({"TEXT":"18"}))    #set font size 18
-        xSizeFontEast.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-        xSizeFontEast.executeAction("TYPE", mkPropertyValues({"TEXT":"18"}))    #set font size 18
-        xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-        xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"TEXT":"18"}))    #set font size 18
-        select_pos(xLangFont, "0")
-        select_pos(xLangFontEast, "0")
-        select_pos(xLangFontCTL, "0")
-        xOK = xDialog.getChild("ok")
-        xOK.executeAction("CLICK", tuple())
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "1")  #tab Font
+            xSizeFont = xDialog.getChild("westsizelb-cjk")
+            xSizeFontEast = xDialog.getChild("eastsizelb")
+            xSizeFontCTL = xDialog.getChild("ctlsizelb")
+            xLangFont = xDialog.getChild("westlanglb-cjk")
+            xLangFontEast = xDialog.getChild("eastlanglb")
+            xLangFontCTL = xDialog.getChild("ctllanglb")
+
+            xSizeFont.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+            xSizeFont.executeAction("TYPE", mkPropertyValues({"TEXT":"18"}))    #set font size 18
+            xSizeFontEast.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+            xSizeFontEast.executeAction("TYPE", mkPropertyValues({"TEXT":"18"}))    #set font size 18
+            xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+            xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"TEXT":"18"}))    #set font size 18
+            select_pos(xLangFont, "0")
+            select_pos(xLangFontEast, "0")
+            select_pos(xLangFontCTL, "0")
 
         #Verify - select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "1")  #tab Font
-        xSizeFont = xDialog.getChild("westsizelb-cjk")
-        xSizeFontEast = xDialog.getChild("eastsizelb")
-        xSizeFontCTL = xDialog.getChild("ctlsizelb")
-        xLangFont = xDialog.getChild("westlanglb-cjk")
-        xLangFontEast = xDialog.getChild("eastlanglb")
-        xLangFontCTL = xDialog.getChild("ctllanglb")
-
-        self.assertEqual(get_state_as_dict(xSizeFont)["Text"], "18 pt")
-        self.assertEqual(get_state_as_dict(xSizeFontEast)["Text"], "18 pt")
-        self.assertEqual(get_state_as_dict(xSizeFontCTL)["Text"], "18 pt") #check font size
-        self.assertEqual(get_state_as_dict(xLangFont)["Text"], "[None]")
-        self.assertEqual(get_state_as_dict(xLangFontEast)["SelectEntryText"], "[None]")
-        self.assertEqual(get_state_as_dict(xLangFontCTL)["SelectEntryText"], "[None]")
-
-        xCanc = xDialog.getChild("cancel")
-        self.ui_test.close_dialog_through_button(xCanc)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog", close_button="cancel") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "1")  #tab Font
+            xSizeFont = xDialog.getChild("westsizelb-cjk")
+            xSizeFontEast = xDialog.getChild("eastsizelb")
+            xSizeFontCTL = xDialog.getChild("ctlsizelb")
+            xLangFont = xDialog.getChild("westlanglb-cjk")
+            xLangFontEast = xDialog.getChild("eastlanglb")
+            xLangFontCTL = xDialog.getChild("ctllanglb")
+
+            self.assertEqual(get_state_as_dict(xSizeFont)["Text"], "18 pt")
+            self.assertEqual(get_state_as_dict(xSizeFontEast)["Text"], "18 pt")
+            self.assertEqual(get_state_as_dict(xSizeFontCTL)["Text"], "18 pt") #check font size
+            self.assertEqual(get_state_as_dict(xLangFont)["Text"], "[None]")
+            self.assertEqual(get_state_as_dict(xLangFontEast)["SelectEntryText"], "[None]")
+            self.assertEqual(get_state_as_dict(xLangFontCTL)["SelectEntryText"], "[None]")
+
 
         self.ui_test.close_doc()
 
@@ -140,50 +128,44 @@ class formatCell(UITestCase):
         #select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "2")  #tab Font Effects
-        xRelief = xDialog.getChild("relieflb")
-        xOverline = xDialog.getChild("overlinelb")
-        xStrikeout = xDialog.getChild("strikeoutlb")
-        xUnderline = xDialog.getChild("underlinelb")
-        xEmphasis = xDialog.getChild("emphasislb")
-        xPosition = xDialog.getChild("positionlb")
-
-        select_pos(xRelief, "1")
-        select_pos(xOverline, "1")
-        select_pos(xStrikeout, "1")
-        select_pos(xUnderline, "1")
-        select_pos(xEmphasis, "1")
-        select_pos(xPosition, "1")
-
-        xOK = xDialog.getChild("ok")
-        xOK.executeAction("CLICK", tuple())
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "2")  #tab Font Effects
+            xRelief = xDialog.getChild("relieflb")
+            xOverline = xDialog.getChild("overlinelb")
+            xStrikeout = xDialog.getChild("strikeoutlb")
+            xUnderline = xDialog.getChild("underlinelb")
+            xEmphasis = xDialog.getChild("emphasislb")
+            xPosition = xDialog.getChild("positionlb")
+
+            select_pos(xRelief, "1")
+            select_pos(xOverline, "1")
+            select_pos(xStrikeout, "1")
+            select_pos(xUnderline, "1")
+            select_pos(xEmphasis, "1")
+            select_pos(xPosition, "1")
+
         #Verify- select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "2")
-
-        xRelief = xDialog.getChild("relieflb")
-        xOverline = xDialog.getChild("overlinelb")
-        xStrikeout = xDialog.getChild("strikeoutlb")
-        xUnderline = xDialog.getChild("underlinelb")
-        xEmphasis = xDialog.getChild("emphasislb")
-        xPosition = xDialog.getChild("positionlb")
-
-        self.assertEqual(get_state_as_dict(xRelief)["SelectEntryText"], "Embossed")
-        self.assertEqual(get_state_as_dict(xOverline)["SelectEntryText"], "Single")
-        self.assertEqual(get_state_as_dict(xStrikeout)["SelectEntryText"], "Single")
-        self.assertEqual(get_state_as_dict(xUnderline)["SelectEntryText"], "Single")
-        self.assertEqual(get_state_as_dict(xEmphasis)["SelectEntryText"], "Dot")
-        self.assertEqual(get_state_as_dict(xPosition)["SelectEntryText"], "Below text")
-
-        xCanc = xDialog.getChild("cancel")
-        self.ui_test.close_dialog_through_button(xCanc)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog", close_button="cancel") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "2")
+
+            xRelief = xDialog.getChild("relieflb")
+            xOverline = xDialog.getChild("overlinelb")
+            xStrikeout = xDialog.getChild("strikeoutlb")
+            xUnderline = xDialog.getChild("underlinelb")
+            xEmphasis = xDialog.getChild("emphasislb")
+            xPosition = xDialog.getChild("positionlb")
+
+            self.assertEqual(get_state_as_dict(xRelief)["SelectEntryText"], "Embossed")
+            self.assertEqual(get_state_as_dict(xOverline)["SelectEntryText"], "Single")
+            self.assertEqual(get_state_as_dict(xStrikeout)["SelectEntryText"], "Single")
+            self.assertEqual(get_state_as_dict(xUnderline)["SelectEntryText"], "Single")
+            self.assertEqual(get_state_as_dict(xEmphasis)["SelectEntryText"], "Dot")
+            self.assertEqual(get_state_as_dict(xPosition)["SelectEntryText"], "Below text")
+
 
         self.ui_test.close_doc()
 
@@ -195,52 +177,46 @@ class formatCell(UITestCase):
         #select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "3")  #tab Alignment
-        comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign")
-        xspinIndentFrom = xDialog.getChild("spinIndentFrom")
-        xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign")
-        xcheckVertStack = xDialog.getChild("checkVertStack")
-        xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto")
-        xcheckHyphActive = xDialog.getChild("checkHyphActive")
-        xcomboTextDirBox = xDialog.getChild("comboTextDirBox")
-
-        select_by_text(comboboxHorzAlign, "Left")
-        xspinIndentFrom.executeAction("UP", tuple())
-        indentVal = get_state_as_dict(xspinIndentFrom)["Text"]
-        select_by_text(xcomboboxVertAlign, "Top")
-        xcheckVertStack.executeAction("CLICK", tuple())
-        xcheckWrapTextAuto.executeAction("CLICK", tuple())
-        xcheckHyphActive.executeAction("CLICK", tuple())
-        select_by_text(xcomboTextDirBox, "Left-to-right (LTR)")
-        xOK = xDialog.getChild("ok")
-        xOK.executeAction("CLICK", tuple())
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "3")  #tab Alignment
+            comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign")
+            xspinIndentFrom = xDialog.getChild("spinIndentFrom")
+            xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign")
+            xcheckVertStack = xDialog.getChild("checkVertStack")
+            xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto")
+            xcheckHyphActive = xDialog.getChild("checkHyphActive")
+            xcomboTextDirBox = xDialog.getChild("comboTextDirBox")
+
+            select_by_text(comboboxHorzAlign, "Left")
+            xspinIndentFrom.executeAction("UP", tuple())
+            indentVal = get_state_as_dict(xspinIndentFrom)["Text"]
+            select_by_text(xcomboboxVertAlign, "Top")
+            xcheckVertStack.executeAction("CLICK", tuple())
+            xcheckWrapTextAuto.executeAction("CLICK", tuple())
+            xcheckHyphActive.executeAction("CLICK", tuple())
+            select_by_text(xcomboTextDirBox, "Left-to-right (LTR)")
         #Verify- select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "3")
-        comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign")
-        xspinIndentFrom = xDialog.getChild("spinIndentFrom")
-        xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign")
-        xcheckVertStack = xDialog.getChild("checkVertStack")
-        xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto")
-        xcheckHyphActive = xDialog.getChild("checkHyphActive")
-        xcomboTextDirBox = xDialog.getChild("comboTextDirBox")
-
-        self.assertEqual(get_state_as_dict(comboboxHorzAlign)["SelectEntryText"], "Left")
-        self.assertEqual(get_state_as_dict(xspinIndentFrom)["Text"] == indentVal, True)
-        self.assertEqual(get_state_as_dict(xcomboboxVertAlign)["SelectEntryText"], "Top")
-        self.assertEqual(get_state_as_dict(xcheckVertStack)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(xcheckWrapTextAuto)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(xcheckHyphActive)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(xcomboTextDirBox)["SelectEntryText"], "Left-to-right (LTR)")
-        xOK = xDialog.getChild("ok")
-        xOK.executeAction("CLICK", tuple())
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "3")
+            comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign")
+            xspinIndentFrom = xDialog.getChild("spinIndentFrom")
+            xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign")
+            xcheckVertStack = xDialog.getChild("checkVertStack")
+            xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto")
+            xcheckHyphActive = xDialog.getChild("checkHyphActive")
+            xcomboTextDirBox = xDialog.getChild("comboTextDirBox")
+
+            self.assertEqual(get_state_as_dict(comboboxHorzAlign)["SelectEntryText"], "Left")
+            self.assertEqual(get_state_as_dict(xspinIndentFrom)["Text"] == indentVal, True)
+            self.assertEqual(get_state_as_dict(xcomboboxVertAlign)["SelectEntryText"], "Top")
+            self.assertEqual(get_state_as_dict(xcheckVertStack)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(xcheckWrapTextAuto)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(xcheckHyphActive)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(xcomboTextDirBox)["SelectEntryText"], "Left-to-right (LTR)")
 
         self.ui_test.close_doc()
 
@@ -252,25 +228,19 @@ class formatCell(UITestCase):
         #select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "4")  #tab Asian typography
-        xcheckForbidList = xDialog.getChild("checkForbidList")
-        xcheckForbidList.executeAction("CLICK", tuple())
-        xOK = xDialog.getChild("ok")
-        xOK.executeAction("CLICK", tuple())
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "4")  #tab Asian typography
+            xcheckForbidList = xDialog.getChild("checkForbidList")
+            xcheckForbidList.executeAction("CLICK", tuple())
         #Verify- select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "4")
-        xcheckForbidList = xDialog.getChild("checkForbidList")
-        self.assertEqual(get_state_as_dict(xcheckForbidList)["Selected"], "true")
-        xOK = xDialog.getChild("ok")
-        xOK.executeAction("CLICK", tuple())
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "4")
+            xcheckForbidList = xDialog.getChild("checkForbidList")
+            self.assertEqual(get_state_as_dict(xcheckForbidList)["Selected"], "true")
 
         self.ui_test.close_doc()
 
@@ -287,43 +257,40 @@ class formatCell(UITestCase):
         #select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "5")  #tab Borders
-
-        linewidthmf = xDialog.getChild("linewidthmf")
-        xLineSet = xDialog.getChild('lineset')
-
-        # check line-width for default solid line
-        self.assertEqual('0', get_state_as_dict(xLineSet)['SelectedItemPos'])
-        widthVal = get_state_as_dict(linewidthmf)["Text"]
-        self.assertEqual(widthVal, '0.75 pt')
-
-        # set line style to "double" (minimal width is taken)
-        xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": '16'}))
-        widthVal = get_state_as_dict(linewidthmf)["Text"]
-        self.assertEqual(widthVal, '1.10 pt')
-
-        # set line style to "solid"
-        xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "1"}))
-        widthVal = get_state_as_dict(linewidthmf)["Text"]
-        self.assertEqual(widthVal, '0.75 pt')
-
-        # make custom line width
-        linewidthmf.executeAction("UP", tuple())
-        linewidthmf.executeAction("UP", tuple())
-        linewidthmf.executeAction("UP", tuple())
-        widthVal = get_state_as_dict(linewidthmf)["Text"]
-        self.assertEqual(widthVal, '1.50 pt')
-
-        # set line style to "double" (minimal width is not taken)
-        xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "8"}))
-        widthVal = get_state_as_dict(linewidthmf)["Text"]
-        self.assertEqual(widthVal, '1.50 pt')
-
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "5")  #tab Borders
+
+            linewidthmf = xDialog.getChild("linewidthmf")
+            xLineSet = xDialog.getChild('lineset')
+
+            # check line-width for default solid line
+            self.assertEqual('0', get_state_as_dict(xLineSet)['SelectedItemPos'])
+            widthVal = get_state_as_dict(linewidthmf)["Text"]
+            self.assertEqual(widthVal, '0.75 pt')
+
+            # set line style to "double" (minimal width is taken)
+            xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": '16'}))
+            widthVal = get_state_as_dict(linewidthmf)["Text"]
+            self.assertEqual(widthVal, '1.10 pt')
+
+            # set line style to "solid"
+            xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "1"}))
+            widthVal = get_state_as_dict(linewidthmf)["Text"]
+            self.assertEqual(widthVal, '0.75 pt')
+
+            # make custom line width
+            linewidthmf.executeAction("UP", tuple())
+            linewidthmf.executeAction("UP", tuple())
+            linewidthmf.executeAction("UP", tuple())
+            widthVal = get_state_as_dict(linewidthmf)["Text"]
+            self.assertEqual(widthVal, '1.50 pt')
+
+            # set line style to "double" (minimal width is not taken)
+            xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "8"}))
+            widthVal = get_state_as_dict(linewidthmf)["Text"]
+            self.assertEqual(widthVal, '1.50 pt')
+
 
         self.ui_test.close_doc()
 
@@ -340,57 +307,51 @@ class formatCell(UITestCase):
         #select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "5")  #tab Borders
-        xsync = xDialog.getChild("sync")
-        xleftmf = xDialog.getChild("leftmf")
-        xrightmf = xDialog.getChild("rightmf")
-        xtopmf = xDialog.getChild("topmf")
-        xbottommf = xDialog.getChild("bottommf")
-
-        xsync.executeAction("CLICK", tuple())  #uncheck Synchronize
-        xleftmf.executeAction("UP", tuple())
-        xrightmf.executeAction("UP", tuple())
-        xrightmf.executeAction("UP", tuple())
-        xtopmf.executeAction("UP", tuple())
-        xtopmf.executeAction("UP", tuple())
-        xtopmf.executeAction("UP", tuple())
-        xbottommf.executeAction("UP", tuple())
-        xbottommf.executeAction("UP", tuple())
-        xbottommf.executeAction("UP", tuple())
-        xbottommf.executeAction("UP", tuple())
-
-        leftVal = get_state_as_dict(xleftmf)["Text"]
-        rightVal = get_state_as_dict(xrightmf)["Text"]
-        topVal = get_state_as_dict(xtopmf)["Text"]
-        bottomVal = get_state_as_dict(xbottommf)["Text"]
-
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "5")  #tab Borders
+            xsync = xDialog.getChild("sync")
+            xleftmf = xDialog.getChild("leftmf")
+            xrightmf = xDialog.getChild("rightmf")
+            xtopmf = xDialog.getChild("topmf")
+            xbottommf = xDialog.getChild("bottommf")
+
+            xsync.executeAction("CLICK", tuple())  #uncheck Synchronize
+            xleftmf.executeAction("UP", tuple())
+            xrightmf.executeAction("UP", tuple())
+            xrightmf.executeAction("UP", tuple())
+            xtopmf.executeAction("UP", tuple())
+            xtopmf.executeAction("UP", tuple())
+            xtopmf.executeAction("UP", tuple())
+            xbottommf.executeAction("UP", tuple())
+            xbottommf.executeAction("UP", tuple())
+            xbottommf.executeAction("UP", tuple())
+            xbottommf.executeAction("UP", tuple())
+
+            leftVal = get_state_as_dict(xleftmf)["Text"]
+            rightVal = get_state_as_dict(xrightmf)["Text"]
+            topVal = get_state_as_dict(xtopmf)["Text"]
+            bottomVal = get_state_as_dict(xbottommf)["Text"]
+
 
         # Verify select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "5")  #tab Borders
-        xsync = xDialog.getChild("sync")
-        xleftmf = xDialog.getChild("leftmf")
-        xrightmf = xDialog.getChild("rightmf")
-        xtopmf = xDialog.getChild("topmf")
-        xbottommf = xDialog.getChild("bottommf")
-
-        self.assertEqual(get_state_as_dict(xsync)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(xleftmf)["Text"] == leftVal, True)
-        self.assertEqual(get_state_as_dict(xrightmf)["Text"] == rightVal, True)
-        self.assertEqual(get_state_as_dict(xtopmf)["Text"] == topVal, True)
-        self.assertEqual(get_state_as_dict(xbottommf)["Text"] == bottomVal, True)
-
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "5")  #tab Borders
+            xsync = xDialog.getChild("sync")
+            xleftmf = xDialog.getChild("leftmf")
+            xrightmf = xDialog.getChild("rightmf")
+            xtopmf = xDialog.getChild("topmf")
+            xbottommf = xDialog.getChild("bottommf")
+
+            self.assertEqual(get_state_as_dict(xsync)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(xleftmf)["Text"] == leftVal, True)
+            self.assertEqual(get_state_as_dict(xrightmf)["Text"] == rightVal, True)
+            self.assertEqual(get_state_as_dict(xtopmf)["Text"] == topVal, True)
+            self.assertEqual(get_state_as_dict(xbottommf)["Text"] == bottomVal, True)
+
 
         self.ui_test.close_doc()
 
@@ -403,37 +364,31 @@ class formatCell(UITestCase):
         #select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "6")  #tab Cell protection
-        xcheckHideFormula = xDialog.getChild("checkHideFormula")
-        xcheckHideAll = xDialog.getChild("checkHideAll")
-        xcheckHidePrinting = xDialog.getChild("checkHidePrinting")
-
-        xcheckHideFormula.executeAction("CLICK", tuple())
-        xcheckHideAll.executeAction("CLICK", tuple())
-        xcheckHidePrinting.executeAction("CLICK", tuple())
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "6")  #tab Cell protection
+            xcheckHideFormula = xDialog.getChild("checkHideFormula")
+            xcheckHideAll = xDialog.getChild("checkHideAll")
+            xcheckHidePrinting = xDialog.getChild("checkHidePrinting")
+
+            xcheckHideFormula.executeAction("CLICK", tuple())
+            xcheckHideAll.executeAction("CLICK", tuple())
+            xcheckHidePrinting.executeAction("CLICK", tuple())
 
         # Verify select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "6")  #tab Borders
-        xcheckHideFormula = xDialog.getChild("checkHideFormula")
-        xcheckHideAll = xDialog.getChild("checkHideAll")
-        xcheckHidePrinting = xDialog.getChild("checkHidePrinting")
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "6")  #tab Borders
+            xcheckHideFormula = xDialog.getChild("checkHideFormula")
+            xcheckHideAll = xDialog.getChild("checkHideAll")
+            xcheckHidePrinting = xDialog.getChild("checkHidePrinting")
 
-        self.assertEqual(get_state_as_dict(xcheckHideFormula)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(xcheckHideAll)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(xcheckHidePrinting)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(xcheckHideFormula)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(xcheckHideAll)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(xcheckHidePrinting)["Selected"], "false")
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         self.ui_test.close_doc()
 
@@ -445,19 +400,16 @@ class formatCell(UITestCase):
         #select cell A1
         gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
         #format - cell
-        self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "3")  #tab Alignment
-        xspinDegrees = xDialog.getChild("spinDegrees")
-        self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0")
-        xspinDegrees.executeAction("DOWN", tuple())
-        self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "355")
-        xspinDegrees.executeAction("UP", tuple())
-        self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0")
-
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+        with self.ui_test.execute_dialog_through_command_guarded(".uno:FormatCellDialog") as xDialog:
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "3")  #tab Alignment
+            xspinDegrees = xDialog.getChild("spinDegrees")
+            self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0")
+            xspinDegrees.executeAction("DOWN", tuple())
+            self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "355")
+            xspinDegrees.executeAction("UP", tuple())
+            self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0")
+
 
         self.ui_test.close_doc()
 
diff --git a/sc/qa/uitest/calc_tests/mergedRowsColumns.py b/sc/qa/uitest/calc_tests/mergedRowsColumns.py
index 2bc225d1f84d..f0c6b5ba9ac2 100644
--- a/sc/qa/uitest/calc_tests/mergedRowsColumns.py
+++ b/sc/qa/uitest/calc_tests/mergedRowsColumns.py
@@ -64,12 +64,9 @@ class mergedRowsColumns(UITestCase):
 
             #move the content of the hidden cells into the first cell
             gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A11:A12"}))
-            self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells")
-            xDialog = self.xUITest.getTopFocusWindow()
-
-            xMoveCells = xDialog.getChild("move-cells-radio")
-            xMoveCells.executeAction("CLICK", tuple())
-            self.ui_test.close_dialog_through_button(xDialog.getChild("ok"))
+            with self.ui_test.execute_dialog_through_command_guarded(".uno:ToggleMergeCells") as xDialog:
+                xMoveCells = xDialog.getChild("move-cells-radio")
+                xMoveCells.executeAction("CLICK", tuple())
             self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 10).getString(), "2 3")
             self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 11).getString(), "0")
 
@@ -79,12 +76,9 @@ class mergedRowsColumns(UITestCase):
 
             #keep the contents of the hidden cells
             gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A11:A12"}))
-            self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells")
-            xDialog = self.xUITest.getTopFocusWindow()
-
-            xMoveCells = xDialog.getChild("keep-content-radio")
-            xMoveCells.executeAction("CLICK", tuple())
-            self.ui_test.close_dialog_through_button(xDialog.getChild("ok"))

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list