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

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 25 16:22:02 UTC 2021


 sc/qa/uitest/calc_tests9/tdf124318.py        |   18 
 sc/qa/uitest/chart/chartArea.py              |  140 ++---
 sc/qa/uitest/chart/chartAxes.py              |   42 -
 sc/qa/uitest/chart/chartDataLabels.py        |  298 +++++------
 sc/qa/uitest/chart/chartGrid.py              |  172 ++----
 sc/qa/uitest/chart/chartGrids.py             |   71 +-
 sc/qa/uitest/chart/chartLegend.py            |   11 
 sc/qa/uitest/chart/chartTitles.py            |   90 +--
 sc/qa/uitest/chart/chartWall.py              |  166 ++----
 sc/qa/uitest/chart/chartXAxis.py             |  354 ++++++-------
 sc/qa/uitest/chart/chartYAxis.py             |  358 ++++++-------
 sc/qa/uitest/chart/edit_chart.py             |    9 
 sc/qa/uitest/chart/formatDataSeries.py       |  134 ++---
 sc/qa/uitest/chart/tdf122398.py              |   92 +--
 sc/qa/uitest/chart/tdf123013.py              |   34 -
 sc/qa/uitest/chart/tdf123231.py              |   57 --
 sc/qa/uitest/chart/tdf123520.py              |   70 +-
 sc/qa/uitest/chart/tdf124111.py              |   58 --
 sc/qa/uitest/chart/tdf129587.py              |   31 -
 sc/qa/uitest/chart/tdf133630.py              |   28 -
 sc/qa/uitest/chart/tdf134059.py              |   19 
 sc/qa/uitest/chart/tdf142851.py              |   10 
 sc/qa/uitest/chart/tdf93506_trendline.py     |  706 ++++++++++++---------------
 sc/qa/uitest/chart/tdf96432.py               |   36 -
 sc/qa/uitest/chart/tdf99069.py               |   27 -
 sc/qa/uitest/conditional_format/tdf100793.py |   52 -
 sc/qa/uitest/conditional_format/tdf105544.py |    7 
 sc/qa/uitest/conditional_format/tdf96453.py  |    7 
 sw/qa/uitest/chart/tdf138556.py              |   22 
 sw/qa/uitest/writer_tests4/tdf134439.py      |   19 
 sw/qa/uitest/writer_tests4/tdf135636.py      |   13 
 sw/qa/uitest/writer_tests6/tdf131041.py      |   13 
 uitest/uitest/test.py                        |   10 
 uitest/uitest/uihelper/guarded.py            |   10 
 34 files changed, 1455 insertions(+), 1729 deletions(-)

New commits:
commit 8a2d7c797958680bcf133fef44abcf2efd1007d1
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Wed Jun 23 12:14:24 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri Jun 25 18:21:22 2021 +0200

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

diff --git a/sc/qa/uitest/calc_tests9/tdf124318.py b/sc/qa/uitest/calc_tests9/tdf124318.py
index 8aad127c608e..80a1d004b941 100644
--- a/sc/qa/uitest/calc_tests9/tdf124318.py
+++ b/sc/qa/uitest/calc_tests9/tdf124318.py
@@ -19,15 +19,13 @@ class tdf124318(UITestCase):
 
             gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B4"}))
 
-            self.ui_test.execute_dialog_through_action(gridwin, "TYPE", mkPropertyValues({"KEYCODE": "CTRL+k"}))
-            xDialog = self.xUITest.getTopFocusWindow()
-
-            # Without the fix in place, this test would have failed with
-            # AssertionError: 'mobile/identification/authentification' !=
-            # 'mobile/identification/authentification%00塹\uf481ᴻ䡿ⲯ嶂藄挧%00%00ꮥ%00'
-            self.assertEqual("mobile/identification/authentification",
-                    get_state_as_dict(xDialog.getChild("target"))['Text'].split(".fr/")[1])
-            self.assertEqual("mobile/identification/authentification",
-                    get_state_as_dict(xDialog.getChild("indication"))['Text'].split(".fr/")[1])
+            with self.ui_test.execute_dialog_through_action(gridwin, "TYPE", mkPropertyValues({"KEYCODE": "CTRL+k"})) as xDialog:
+                # Without the fix in place, this test would have failed with
+                # AssertionError: 'mobile/identification/authentification' !=
+                # 'mobile/identification/authentification%00塹\uf481ᴻ䡿ⲯ嶂藄挧%00%00ꮥ%00'
+                self.assertEqual("mobile/identification/authentification",
+                        get_state_as_dict(xDialog.getChild("target"))['Text'].split(".fr/")[1])
+                self.assertEqual("mobile/identification/authentification",
+                        get_state_as_dict(xDialog.getChild("indication"))['Text'].split(".fr/")[1])
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/chart/chartArea.py b/sc/qa/uitest/chart/chartArea.py
index d7a744749188..05aac7a5bf8e 100644
--- a/sc/qa/uitest/chart/chartArea.py
+++ b/sc/qa/uitest/chart/chartArea.py
@@ -34,20 +34,17 @@ class chartArea(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramArea"}))
-        xDialog = self.xUITest.getTopFocusWindow()
-        #Click on tab "Borders".
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramArea"})) as xDialog:
+            #Click on tab "Borders".
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
 
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
 
-        xWidth.executeAction("UP", tuple())
-        transparency.executeAction("UP", tuple())
+            xWidth.executeAction("UP", tuple())
+            transparency.executeAction("UP", tuple())
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         self.assertEqual(xArea.LineWidth, 100)
         self.assertEqual(xArea.LineTransparence, 5)
@@ -60,43 +57,40 @@ class chartArea(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramArea"}))
-        xDialog = self.xUITest.getTopFocusWindow()
-
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
-
-        self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
-        self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
-
-        #Click on tab "Area"
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "1")
-
-        btncolor = xDialog.getChild("btncolor")
-        btncolor.executeAction("CLICK", tuple())
-
-        rCustom = xDialog.getChild("R_custom")
-        gCustom = xDialog.getChild("G_custom")
-        bCustom = xDialog.getChild("B_custom")
-
-        rCustom.executeAction("CLEAR", tuple())
-        rCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"35"}))
-        rCustom.executeAction("UP", tuple())
-        rCustom.executeAction("DOWN", tuple())  #without this save data doesn't works
-        self.assertEqual(get_state_as_dict(rCustom)["Text"], "35")
-        gCustom.executeAction("CLEAR", tuple())
-        gCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"169"}))
-        gCustom.executeAction("UP", tuple())
-        gCustom.executeAction("DOWN", tuple())  #without this save data doesn't works
-        bCustom.executeAction("CLEAR", tuple())
-        bCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"211"}))
-        bCustom.executeAction("UP", tuple())
-        bCustom.executeAction("DOWN", tuple())  #without this save data doesn't works
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramArea"})) as xDialog:
+
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+
+            self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
+            self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
+
+            #Click on tab "Area"
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "1")
+
+            btncolor = xDialog.getChild("btncolor")
+            btncolor.executeAction("CLICK", tuple())
+
+            rCustom = xDialog.getChild("R_custom")
+            gCustom = xDialog.getChild("G_custom")
+            bCustom = xDialog.getChild("B_custom")
+
+            rCustom.executeAction("CLEAR", tuple())
+            rCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"35"}))
+            rCustom.executeAction("UP", tuple())
+            rCustom.executeAction("DOWN", tuple())  #without this save data doesn't works
+            self.assertEqual(get_state_as_dict(rCustom)["Text"], "35")
+            gCustom.executeAction("CLEAR", tuple())
+            gCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"169"}))
+            gCustom.executeAction("UP", tuple())
+            gCustom.executeAction("DOWN", tuple())  #without this save data doesn't works
+            bCustom.executeAction("CLEAR", tuple())
+            bCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"211"}))
+            bCustom.executeAction("UP", tuple())
+            bCustom.executeAction("DOWN", tuple())  #without this save data doesn't works
 
         self.assertEqual(xArea.LineWidth, 100)
         self.assertEqual(xArea.LineTransparence, 5)
@@ -109,30 +103,27 @@ class chartArea(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramArea"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramArea"})) as xDialog:
 
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "1")
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "1")
 
-        rCustom = xDialog.getChild("R_custom")
-        gCustom = xDialog.getChild("G_custom")
-        bCustom = xDialog.getChild("B_custom")
+            rCustom = xDialog.getChild("R_custom")
+            gCustom = xDialog.getChild("G_custom")
+            bCustom = xDialog.getChild("B_custom")
 
-        self.assertEqual(get_state_as_dict(rCustom)["Text"], "35")
-        self.assertEqual(get_state_as_dict(gCustom)["Text"], "169")
-        self.assertEqual(get_state_as_dict(bCustom)["Text"], "211")
+            self.assertEqual(get_state_as_dict(rCustom)["Text"], "35")
+            self.assertEqual(get_state_as_dict(gCustom)["Text"], "169")
+            self.assertEqual(get_state_as_dict(bCustom)["Text"], "211")
 
-        #change tab "Transparency"
-        select_pos(tabcontrol, "2")
-        transparency = xDialog.getChild("RBT_TRANS_LINEAR")
-        transparencyPercent = xDialog.getChild("MTR_TRANSPARENT")  #51%
+            #change tab "Transparency"
+            select_pos(tabcontrol, "2")
+            transparency = xDialog.getChild("RBT_TRANS_LINEAR")
+            transparencyPercent = xDialog.getChild("MTR_TRANSPARENT")  #51%
 
-        transparency.executeAction("CLICK", tuple())
-        transparencyPercent.executeAction("UP", tuple())
+            transparency.executeAction("CLICK", tuple())
+            transparencyPercent.executeAction("UP", tuple())
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         self.assertEqual(xArea.LineWidth, 100)
         self.assertEqual(xArea.LineTransparence, 5)
@@ -145,20 +136,17 @@ class chartArea(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramArea"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramArea"})) as xDialog:
 
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "2")
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "2")
 
-        transparency = xDialog.getChild("RBT_TRANS_LINEAR")
-        transparencyPercent = xDialog.getChild("MTR_TRANSPARENT")  #51%
+            transparency = xDialog.getChild("RBT_TRANS_LINEAR")
+            transparencyPercent = xDialog.getChild("MTR_TRANSPARENT")  #51%
 
-        self.assertEqual(get_state_as_dict(transparency)["Checked"], "true")
-        self.assertEqual(get_state_as_dict(transparencyPercent)["Text"], "51%")
+            self.assertEqual(get_state_as_dict(transparency)["Checked"], "true")
+            self.assertEqual(get_state_as_dict(transparencyPercent)["Text"], "51%")
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         self.assertEqual(xArea.LineWidth, 100)
         self.assertEqual(xArea.LineTransparence, 5)
diff --git a/sc/qa/uitest/chart/chartAxes.py b/sc/qa/uitest/chart/chartAxes.py
index 9b8db33aa4e7..e45b48309f13 100644
--- a/sc/qa/uitest/chart/chartAxes.py
+++ b/sc/qa/uitest/chart/chartAxes.py
@@ -25,21 +25,18 @@ class chartAxes(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuAxes"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuAxes"})) as xDialog:
 
-        primaryX = xDialog.getChild("primaryX")
-        primaryY = xDialog.getChild("primaryY")
-        secondaryX = xDialog.getChild("secondaryX")
-        secondaryY = xDialog.getChild("secondaryY")
+            primaryX = xDialog.getChild("primaryX")
+            primaryY = xDialog.getChild("primaryY")
+            secondaryX = xDialog.getChild("secondaryX")
+            secondaryY = xDialog.getChild("secondaryY")
 
-        primaryX.executeAction("CLICK", tuple())
-        primaryY.executeAction("CLICK", tuple())
-        secondaryX.executeAction("CLICK", tuple())
-        secondaryY.executeAction("CLICK", tuple())
+            primaryX.executeAction("CLICK", tuple())
+            primaryY.executeAction("CLICK", tuple())
+            secondaryX.executeAction("CLICK", tuple())
+            secondaryY.executeAction("CLICK", tuple())
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         #reopen and verify Grids dialog
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -47,20 +44,17 @@ class chartAxes(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuAxes"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuAxes"})) as xDialog:
 
-        primaryX = xDialog.getChild("primaryX")
-        primaryY = xDialog.getChild("primaryY")
-        secondaryX = xDialog.getChild("secondaryX")
-        secondaryY = xDialog.getChild("secondaryY")
+            primaryX = xDialog.getChild("primaryX")
+            primaryY = xDialog.getChild("primaryY")
+            secondaryX = xDialog.getChild("secondaryX")
+            secondaryY = xDialog.getChild("secondaryY")
 
-        self.assertEqual(get_state_as_dict(primaryX)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(primaryY)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(secondaryX)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(secondaryY)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(primaryX)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(primaryY)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(secondaryX)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(secondaryY)["Selected"], "true")
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/chart/chartDataLabels.py b/sc/qa/uitest/chart/chartDataLabels.py
index 0d5bae2f0333..bbf82bab76f3 100644
--- a/sc/qa/uitest/chart/chartDataLabels.py
+++ b/sc/qa/uitest/chart/chartDataLabels.py
@@ -36,38 +36,35 @@ class chartDataLabels(UITestCase):
         self.assertFalse(xDataSeries[0].Label.ShowLegendSymbol)
         self.assertEqual(xDataSeries[0].LabelSeparator, " ")
 
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuDataLabels"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuDataLabels"})) as xDialog:
 
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "1")
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "1")
 
-        self.assertTrue(xDataSeries[0].Label.ShowNumber)
-        self.assertFalse(xDataSeries[0].Label.ShowCategoryName)
-        self.assertFalse(xDataSeries[0].Label.ShowLegendSymbol)
-        self.assertEqual(xDataSeries[0].LabelSeparator, " ")
+            self.assertTrue(xDataSeries[0].Label.ShowNumber)
+            self.assertFalse(xDataSeries[0].Label.ShowCategoryName)
+            self.assertFalse(xDataSeries[0].Label.ShowLegendSymbol)
+            self.assertEqual(xDataSeries[0].LabelSeparator, " ")
 
-        valueAsNumber = xDialog.getChild("CB_VALUE_AS_NUMBER")
-        category = xDialog.getChild("CB_CATEGORY")
-        legend = xDialog.getChild("CB_SYMBOL")
-        wrapText = xDialog.getChild("CB_WRAP_TEXT")
-        separator = xDialog.getChild("LB_TEXT_SEPARATOR")
-        placement = xDialog.getChild("LB_LABEL_PLACEMENT")
-        degrees = xDialog.getChild("NF_LABEL_DEGREES")
-        textDirection = xDialog.getChild("LB_LABEL_TEXTDIR")
+            valueAsNumber = xDialog.getChild("CB_VALUE_AS_NUMBER")
+            category = xDialog.getChild("CB_CATEGORY")
+            legend = xDialog.getChild("CB_SYMBOL")
+            wrapText = xDialog.getChild("CB_WRAP_TEXT")
+            separator = xDialog.getChild("LB_TEXT_SEPARATOR")
+            placement = xDialog.getChild("LB_LABEL_PLACEMENT")
+            degrees = xDialog.getChild("NF_LABEL_DEGREES")
+            textDirection = xDialog.getChild("LB_LABEL_TEXTDIR")
 
-        #valueAsNumber.executeAction("CLICK", tuple())
-        category.executeAction("CLICK", tuple())
-        legend.executeAction("CLICK", tuple())
-        wrapText.executeAction("CLICK", tuple())
-        select_by_text(separator, "Comma")
+            #valueAsNumber.executeAction("CLICK", tuple())
+            category.executeAction("CLICK", tuple())
+            legend.executeAction("CLICK", tuple())
+            wrapText.executeAction("CLICK", tuple())
+            select_by_text(separator, "Comma")
 
-        select_by_text(placement, "Below")
-        degrees.executeAction("UP", tuple())
-        select_by_text(textDirection, "Right-to-left")
+            select_by_text(placement, "Below")
+            degrees.executeAction("UP", tuple())
+            select_by_text(textDirection, "Right-to-left")
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         self.assertTrue(xDataSeries[0].Label.ShowNumber)
         self.assertTrue(xDataSeries[0].Label.ShowCategoryName)
@@ -80,37 +77,34 @@ class chartDataLabels(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuDataLabels"}))
-        xDialog = self.xUITest.getTopFocusWindow()
-
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "1")
-
-        self.assertTrue(xDataSeries[0].Label.ShowNumber)
-        self.assertTrue(xDataSeries[0].Label.ShowCategoryName)
-        self.assertTrue(xDataSeries[0].Label.ShowLegendSymbol)
-        self.assertEqual(xDataSeries[0].LabelSeparator, ", ")
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuDataLabels"})) as xDialog:
+
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "1")
+
+            self.assertTrue(xDataSeries[0].Label.ShowNumber)
+            self.assertTrue(xDataSeries[0].Label.ShowCategoryName)
+            self.assertTrue(xDataSeries[0].Label.ShowLegendSymbol)
+            self.assertEqual(xDataSeries[0].LabelSeparator, ", ")
+
+            valueAsNumber = xDialog.getChild("CB_VALUE_AS_NUMBER")
+            category = xDialog.getChild("CB_CATEGORY")
+            legend = xDialog.getChild("CB_SYMBOL")
+            wrapText = xDialog.getChild("CB_WRAP_TEXT")
+            separator = xDialog.getChild("LB_TEXT_SEPARATOR")
+            placement = xDialog.getChild("LB_LABEL_PLACEMENT")
+            degrees = xDialog.getChild("NF_LABEL_DEGREES")
+            textDirection = xDialog.getChild("LB_LABEL_TEXTDIR")
+
+            self.assertEqual(get_state_as_dict(valueAsNumber)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(category)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(legend)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(wrapText)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(separator)["SelectEntryText"], "Comma")
+            self.assertEqual(get_state_as_dict(placement)["SelectEntryText"], "Below")
+            self.assertEqual(get_state_as_dict(degrees)["Text"], "1°")
+            self.assertEqual(get_state_as_dict(textDirection)["SelectEntryText"], "Right-to-left")
 
-        valueAsNumber = xDialog.getChild("CB_VALUE_AS_NUMBER")
-        category = xDialog.getChild("CB_CATEGORY")
-        legend = xDialog.getChild("CB_SYMBOL")
-        wrapText = xDialog.getChild("CB_WRAP_TEXT")
-        separator = xDialog.getChild("LB_TEXT_SEPARATOR")
-        placement = xDialog.getChild("LB_LABEL_PLACEMENT")
-        degrees = xDialog.getChild("NF_LABEL_DEGREES")
-        textDirection = xDialog.getChild("LB_LABEL_TEXTDIR")
-
-        self.assertEqual(get_state_as_dict(valueAsNumber)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(category)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(legend)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(wrapText)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(separator)["SelectEntryText"], "Comma")
-        self.assertEqual(get_state_as_dict(placement)["SelectEntryText"], "Below")
-        self.assertEqual(get_state_as_dict(degrees)["Text"], "1°")
-        self.assertEqual(get_state_as_dict(textDirection)["SelectEntryText"], "Right-to-left")
-
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         self.assertTrue(xDataSeries[0].Label.ShowNumber)
         self.assertTrue(xDataSeries[0].Label.ShowCategoryName)
@@ -134,51 +128,48 @@ class chartDataLabels(UITestCase):
         self.assertFalse(xDataSeries[0].Label.ShowNumberInPercent)
         self.assertIsNone(xDataSeries[0].PercentageNumberFormat)
 
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatDataLabels"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatDataLabels"})) as xDialog:
+
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "1")
+
+            self.assertTrue(xDataSeries[0].Label.ShowNumber)
+            self.assertFalse(xDataSeries[0].Label.ShowNumberInPercent)
+            self.assertIsNone(xDataSeries[0].PercentageNumberFormat)
+
+            valueAsNumber = xDialog.getChild("CB_VALUE_AS_NUMBER")
+            valueAsPercentage = xDialog.getChild("CB_VALUE_AS_PERCENTAGE")
+            category = xDialog.getChild("CB_CATEGORY")
+            legend = xDialog.getChild("CB_SYMBOL")
+            wrapText = xDialog.getChild("CB_WRAP_TEXT")
+            separator = xDialog.getChild("LB_TEXT_SEPARATOR")
+            placement = xDialog.getChild("LB_LABEL_PLACEMENT")
+            degrees = xDialog.getChild("NF_LABEL_DEGREES")
+            textDirection = xDialog.getChild("LB_LABEL_TEXTDIR")
+            buttonPercentage = xDialog.getChild("PB_PERCENT_NUMBERFORMAT")
+
+            valueAsNumber.executeAction("CLICK", tuple())
+            valueAsPercentage.executeAction("CLICK", tuple())
+            #button Percentage format
+
+            with self.ui_test.execute_blocking_action(buttonPercentage.executeAction, args=('CLICK', ())) as dialog:
+                sourceformat = dialog.getChild("sourceformat")
+                decimalsed = dialog.getChild("decimalsed")
+                leadzerosed = dialog.getChild("leadzerosed")
+                negnumred = dialog.getChild("negnumred")
+                thousands = dialog.getChild("thousands")
+                formatted = dialog.getChild("formatted")
+
+                sourceformat.executeAction("CLICK", tuple())
+                decimalsed.executeAction("UP", tuple())
+                leadzerosed.executeAction("UP", tuple())
+                negnumred.executeAction("CLICK", tuple())
+                thousands.executeAction("CLICK", tuple())
+                self.assertEqual(get_state_as_dict(formatted)["Text"], "#,#00.0%;[RED]-#,#00.0%")
+
+            self.assertEqual(get_state_as_dict(valueAsNumber)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(valueAsPercentage)["Selected"], "true")
 
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "1")
-
-        self.assertTrue(xDataSeries[0].Label.ShowNumber)
-        self.assertFalse(xDataSeries[0].Label.ShowNumberInPercent)
-        self.assertIsNone(xDataSeries[0].PercentageNumberFormat)
-
-        valueAsNumber = xDialog.getChild("CB_VALUE_AS_NUMBER")
-        valueAsPercentage = xDialog.getChild("CB_VALUE_AS_PERCENTAGE")
-        category = xDialog.getChild("CB_CATEGORY")
-        legend = xDialog.getChild("CB_SYMBOL")
-        wrapText = xDialog.getChild("CB_WRAP_TEXT")
-        separator = xDialog.getChild("LB_TEXT_SEPARATOR")
-        placement = xDialog.getChild("LB_LABEL_PLACEMENT")
-        degrees = xDialog.getChild("NF_LABEL_DEGREES")
-        textDirection = xDialog.getChild("LB_LABEL_TEXTDIR")
-        buttonPercentage = xDialog.getChild("PB_PERCENT_NUMBERFORMAT")
-
-        valueAsNumber.executeAction("CLICK", tuple())
-        valueAsPercentage.executeAction("CLICK", tuple())
-        #button Percentage format
-
-        with self.ui_test.execute_blocking_action(buttonPercentage.executeAction, args=('CLICK', ())) as dialog:
-            sourceformat = dialog.getChild("sourceformat")
-            decimalsed = dialog.getChild("decimalsed")
-            leadzerosed = dialog.getChild("leadzerosed")
-            negnumred = dialog.getChild("negnumred")
-            thousands = dialog.getChild("thousands")
-            formatted = dialog.getChild("formatted")
-
-            sourceformat.executeAction("CLICK", tuple())
-            decimalsed.executeAction("UP", tuple())
-            leadzerosed.executeAction("UP", tuple())
-            negnumred.executeAction("CLICK", tuple())
-            thousands.executeAction("CLICK", tuple())
-            self.assertEqual(get_state_as_dict(formatted)["Text"], "#,#00.0%;[RED]-#,#00.0%")
-
-        self.assertEqual(get_state_as_dict(valueAsNumber)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(valueAsPercentage)["Selected"], "true")
-
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         xNumberFormats = document.Sheets[0].Charts[0].getEmbeddedObject().getNumberFormats()
         xLocale = Locale('en', 'US', '')
@@ -194,32 +185,29 @@ class chartDataLabels(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatDataLabels"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatDataLabels"})) as xDialog:
 
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "1")
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "1")
 
-        self.assertFalse(xDataSeries[0].Label.ShowNumber)
-        self.assertTrue(xDataSeries[0].Label.ShowNumberInPercent)
-        self.assertEqual(xDataSeries[0].PercentageNumberFormat, xFormat)
+            self.assertFalse(xDataSeries[0].Label.ShowNumber)
+            self.assertTrue(xDataSeries[0].Label.ShowNumberInPercent)
+            self.assertEqual(xDataSeries[0].PercentageNumberFormat, xFormat)
 
-        valueAsNumber = xDialog.getChild("CB_VALUE_AS_NUMBER")
-        valueAsPercentage = xDialog.getChild("CB_VALUE_AS_PERCENTAGE")
-        category = xDialog.getChild("CB_CATEGORY")
-        legend = xDialog.getChild("CB_SYMBOL")
-        wrapText = xDialog.getChild("CB_WRAP_TEXT")
-        separator = xDialog.getChild("LB_TEXT_SEPARATOR")
-        placement = xDialog.getChild("LB_LABEL_PLACEMENT")
-        degrees = xDialog.getChild("NF_LABEL_DEGREES")
-        textDirection = xDialog.getChild("LB_LABEL_TEXTDIR")
-        buttonPercentage = xDialog.getChild("PB_PERCENT_NUMBERFORMAT")
+            valueAsNumber = xDialog.getChild("CB_VALUE_AS_NUMBER")
+            valueAsPercentage = xDialog.getChild("CB_VALUE_AS_PERCENTAGE")
+            category = xDialog.getChild("CB_CATEGORY")
+            legend = xDialog.getChild("CB_SYMBOL")
+            wrapText = xDialog.getChild("CB_WRAP_TEXT")
+            separator = xDialog.getChild("LB_TEXT_SEPARATOR")
+            placement = xDialog.getChild("LB_LABEL_PLACEMENT")
+            degrees = xDialog.getChild("NF_LABEL_DEGREES")
+            textDirection = xDialog.getChild("LB_LABEL_TEXTDIR")
+            buttonPercentage = xDialog.getChild("PB_PERCENT_NUMBERFORMAT")
 
-        self.assertEqual(get_state_as_dict(valueAsNumber)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(valueAsPercentage)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(valueAsNumber)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(valueAsPercentage)["Selected"], "true")
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         self.assertFalse(xDataSeries[0].Label.ShowNumber)
         self.assertTrue(xDataSeries[0].Label.ShowNumberInPercent)
@@ -241,32 +229,29 @@ class chartDataLabels(UITestCase):
         self.assertTrue(xDataSeries[0].Label.ShowNumber)
         self.assertFalse(xDataSeries[0].Label.ShowNumberInPercent)
 
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatDataLabels"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatDataLabels"})) as xDialog:
 
-        xTabs = xDialog.getChild("tabcontrol")
-        select_pos(xTabs, "1")
+            xTabs = xDialog.getChild("tabcontrol")
+            select_pos(xTabs, "1")
 
-        self.assertTrue(xDataSeries[0].Label.ShowNumber)
-        self.assertFalse(xDataSeries[0].Label.ShowNumberInPercent)
+            self.assertTrue(xDataSeries[0].Label.ShowNumber)
+            self.assertFalse(xDataSeries[0].Label.ShowNumberInPercent)
 
-        xNumberFormatBtn = xDialog.getChild("PB_NUMBERFORMAT")
+            xNumberFormatBtn = xDialog.getChild("PB_NUMBERFORMAT")
 
-        with self.ui_test.execute_blocking_action(xNumberFormatBtn.executeAction, args=('CLICK', ())) as dialog:
-            categoryformat = dialog.getChild("categorylb")
-            formatted = dialog.getChild("formatted")
-            sourceformat = dialog.getChild("sourceformat")
+            with self.ui_test.execute_blocking_action(xNumberFormatBtn.executeAction, args=('CLICK', ())) as dialog:
+                categoryformat = dialog.getChild("categorylb")
+                formatted = dialog.getChild("formatted")
+                sourceformat = dialog.getChild("sourceformat")
 
-            # Select currency
-            sourceformat.executeAction("CLICK", tuple());
-            categoryformat.getChild("4").executeAction("SELECT", tuple());
+                # Select currency
+                sourceformat.executeAction("CLICK", tuple());
+                categoryformat.getChild("4").executeAction("SELECT", tuple());
 
-            self.assertEqual(get_state_as_dict(categoryformat)["SelectEntryText"], "Currency")
+                self.assertEqual(get_state_as_dict(categoryformat)["SelectEntryText"], "Currency")
 
-            self.assertEqual(get_state_as_dict(formatted)["Text"], "[$$-409]#,##0.00;[RED]-[$$-409]#,##0.00")
+                self.assertEqual(get_state_as_dict(formatted)["Text"], "[$$-409]#,##0.00;[RED]-[$$-409]#,##0.00")
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         xNumberFormats = document.Sheets[0].Charts[0].getEmbeddedObject().getNumberFormats()
         xLocale = Locale()
@@ -277,16 +262,13 @@ class chartDataLabels(UITestCase):
         self.assertEqual(xDataSeries[0].NumberFormat, xFormat)
 
         #reopen and verify the previous changes
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatDataLabels"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatDataLabels"})) as xDialog:
 
-        self.assertTrue(xDataSeries[0].Label.ShowNumber)
-        self.assertFalse(xDataSeries[0].Label.ShowNumberInPercent)
-        # tdf#131291: it would fail here: AssertionError: 0 != 104
-        self.assertEqual(xDataSeries[0].NumberFormat, xFormat)
+            self.assertTrue(xDataSeries[0].Label.ShowNumber)
+            self.assertFalse(xDataSeries[0].Label.ShowNumberInPercent)
+            # tdf#131291: it would fail here: AssertionError: 0 != 104
+            self.assertEqual(xDataSeries[0].NumberFormat, xFormat)
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         self.assertTrue(xDataSeries[0].Label.ShowNumber)
         self.assertFalse(xDataSeries[0].Label.ShowNumberInPercent)
@@ -308,27 +290,21 @@ class chartDataLabels(UITestCase):
         xDataLabel = xChartMain.getChild("CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=0")
         xDataLabel.executeAction("SELECT", tuple())
 
-        self.ui_test.execute_dialog_through_action(xDataLabel, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"}))
+        with self.ui_test.execute_dialog_through_action(xDataLabel, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog:
 
-        xDialog = self.xUITest.getTopFocusWindow()
-        self.assertEqual("0.5", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value'])
-        self.assertEqual("2.89", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value'])
+            self.assertEqual("0.5", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value'])
+            self.assertEqual("2.89", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value'])
 
-        # Use OK button in order to test tdf#137165
-        xOkBtn = xDialog.getChild("ok")
-        xOkBtn.executeAction("CLICK", tuple())
+            # Use OK button in order to test tdf#137165
 
         xChartMain.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
         xChartMain.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"}))
 
-        self.ui_test.execute_dialog_through_action(xDataLabel, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"}))
+        with self.ui_test.execute_dialog_through_action(xDataLabel, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog:
 
-        # Check the position has changed after moving the label using the arrows keys
-        xDialog = self.xUITest.getTopFocusWindow()
-        self.assertEqual("0.4", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value'])
-        self.assertEqual("2.79", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value'])
+            # Check the position has changed after moving the label using the arrows keys
+            self.assertEqual("0.4", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value'])
+            self.assertEqual("2.79", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value'])
 
-        xOkBtn = xDialog.getChild("ok")
-        xOkBtn.executeAction("CLICK", tuple())
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/chart/chartGrid.py b/sc/qa/uitest/chart/chartGrid.py
index 7b9814194e51..cbc91f264f6b 100644
--- a/sc/qa/uitest/chart/chartGrid.py
+++ b/sc/qa/uitest/chart/chartGrid.py
@@ -30,20 +30,17 @@ class chartGrid(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYMain"}))
-        xDialog = self.xUITest.getTopFocusWindow()
-        #tab "Line".
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYMain"})) as xDialog:
+            #tab "Line".
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
 
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
 
-        xWidth.executeAction("UP", tuple())
-        transparency.executeAction("UP", tuple())
+            xWidth.executeAction("UP", tuple())
+            transparency.executeAction("UP", tuple())
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         #reopen and verify X Axis Major Grid
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -51,18 +48,15 @@ class chartGrid(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYMain"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYMain"})) as xDialog:
 
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
 
-        self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
-        self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+            self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
+            self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
 
         #Y Axis Major Grid
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -70,20 +64,17 @@ class chartGrid(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridXMain"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridXMain"})) as xDialog:
 
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
 
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
 
-        xWidth.executeAction("UP", tuple())
-        transparency.executeAction("UP", tuple())
+            xWidth.executeAction("UP", tuple())
+            transparency.executeAction("UP", tuple())
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         #reopen and verify Y Axis Major Grid
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -91,20 +82,17 @@ class chartGrid(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridXMain"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridXMain"})) as xDialog:
 
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
 
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
 
-        self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
-        self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
+            self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
+            self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         #Y Axis Minor Grid
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -112,20 +100,17 @@ class chartGrid(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridXHelp"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridXHelp"})) as xDialog:
 
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
 
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
 
-        xWidth.executeAction("UP", tuple())
-        transparency.executeAction("UP", tuple())
+            xWidth.executeAction("UP", tuple())
+            transparency.executeAction("UP", tuple())
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         #reopen and verify Y Axis Minor Grid
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -133,19 +118,16 @@ class chartGrid(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridXHelp"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridXHelp"})) as xDialog:
 
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
 
-        self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
-        self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
+            self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
+            self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         #X Axis Minor Grid
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -153,20 +135,17 @@ class chartGrid(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYHelp"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYHelp"})) as xDialog:
 
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
 
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
 
-        xWidth.executeAction("UP", tuple())
-        transparency.executeAction("UP", tuple())
+            xWidth.executeAction("UP", tuple())
+            transparency.executeAction("UP", tuple())
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         #reopen and verify X Axis Minor Grid
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -174,19 +153,16 @@ class chartGrid(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYHelp"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYHelp"})) as xDialog:
 
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
 
-        self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
-        self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
+            self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
+            self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         #All Grids
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -194,20 +170,17 @@ class chartGrid(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridAll"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridAll"})) as xDialog:
 
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
 
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
 
-        xWidth.executeAction("UP", tuple())
-        transparency.executeAction("UP", tuple())
+            xWidth.executeAction("UP", tuple())
+            transparency.executeAction("UP", tuple())
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         #reopen and verify X Axis Minor Grid  (changed in All Grids)
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -215,18 +188,15 @@ class chartGrid(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYHelp"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramGridYHelp"})) as xDialog:
 
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
 
-        self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.20 cm")
-        self.assertEqual(get_state_as_dict(transparency)["Text"], "10%")
+            self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.20 cm")
+            self.assertEqual(get_state_as_dict(transparency)["Text"], "10%")
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/chart/chartGrids.py b/sc/qa/uitest/chart/chartGrids.py
index b1ffd01b0c49..e7548ba6e0f1 100644
--- a/sc/qa/uitest/chart/chartGrids.py
+++ b/sc/qa/uitest/chart/chartGrids.py
@@ -25,21 +25,18 @@ class chartGrids(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuGrids"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuGrids"})) as xDialog:
 
-        primaryX = xDialog.getChild("primaryX")
-        primaryY = xDialog.getChild("primaryY")
-        secondaryX = xDialog.getChild("secondaryX")
-        secondaryY = xDialog.getChild("secondaryY")
+            primaryX = xDialog.getChild("primaryX")
+            primaryY = xDialog.getChild("primaryY")
+            secondaryX = xDialog.getChild("secondaryX")
+            secondaryY = xDialog.getChild("secondaryY")
 
-        primaryX.executeAction("CLICK", tuple())
-        primaryY.executeAction("CLICK", tuple())
-        secondaryX.executeAction("CLICK", tuple())
-        secondaryY.executeAction("CLICK", tuple())
+            primaryX.executeAction("CLICK", tuple())
+            primaryY.executeAction("CLICK", tuple())
+            secondaryX.executeAction("CLICK", tuple())
+            secondaryY.executeAction("CLICK", tuple())
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         #reopen and verify Grids dialog
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -47,26 +44,23 @@ class chartGrids(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuGrids"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuGrids"})) as xDialog:
 
-        primaryX = xDialog.getChild("primaryX")
-        primaryY = xDialog.getChild("primaryY")
-        secondaryX = xDialog.getChild("secondaryX")
-        secondaryY = xDialog.getChild("secondaryY")
+            primaryX = xDialog.getChild("primaryX")
+            primaryY = xDialog.getChild("primaryY")
+            secondaryX = xDialog.getChild("secondaryX")
+            secondaryY = xDialog.getChild("secondaryY")
 
-        self.assertEqual(get_state_as_dict(primaryX)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(primaryY)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(secondaryX)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(secondaryY)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(primaryX)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(primaryY)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(secondaryX)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(secondaryY)["Selected"], "false")
 
-        primaryX.executeAction("CLICK", tuple())
-        primaryY.executeAction("CLICK", tuple())
-        secondaryX.executeAction("CLICK", tuple())
-        secondaryY.executeAction("CLICK", tuple())
+            primaryX.executeAction("CLICK", tuple())
+            primaryY.executeAction("CLICK", tuple())
+            secondaryX.executeAction("CLICK", tuple())
+            secondaryY.executeAction("CLICK", tuple())
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         #reopen and verify Grids dialog
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -74,20 +68,17 @@ class chartGrids(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuGrids"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuGrids"})) as xDialog:
 
-        primaryX = xDialog.getChild("primaryX")
-        primaryY = xDialog.getChild("primaryY")
-        secondaryX = xDialog.getChild("secondaryX")
-        secondaryY = xDialog.getChild("secondaryY")
+            primaryX = xDialog.getChild("primaryX")
+            primaryY = xDialog.getChild("primaryY")
+            secondaryX = xDialog.getChild("secondaryX")
+            secondaryY = xDialog.getChild("secondaryY")
 
-        self.assertEqual(get_state_as_dict(primaryX)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(primaryY)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(secondaryX)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(secondaryY)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(primaryX)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(primaryY)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(secondaryX)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(secondaryY)["Selected"], "true")
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/chart/chartLegend.py b/sc/qa/uitest/chart/chartLegend.py
index 54929c5c6c30..9128ad040a9a 100644
--- a/sc/qa/uitest/chart/chartLegend.py
+++ b/sc/qa/uitest/chart/chartLegend.py
@@ -11,7 +11,6 @@ from uitest.uihelper.calc import enter_text_to_cell
 from libreoffice.calc.document import get_cell_by_position
 from libreoffice.uno.propertyvalue import mkPropertyValues
 from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, type_text
-from uitest.uihelper import guarded
 
 #Chart Display Legend dialog
 
@@ -27,7 +26,7 @@ class chartLegend(UITestCase):
       xChartMainTop = self.xUITest.getTopFocusWindow()
       xChartMain = xChartMainTop.getChild("chart_window")
       xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-      with guarded.execute_dialog_through_action(self, xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuLegend"})) as xDialog:
+      with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuLegend"})) as xDialog:
         left = xDialog.getChild("left")
         right = xDialog.getChild("right")
         top = xDialog.getChild("top")
@@ -41,7 +40,7 @@ class chartLegend(UITestCase):
       xChartMainTop = self.xUITest.getTopFocusWindow()
       xChartMain = xChartMainTop.getChild("chart_window")
       xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-      with guarded.execute_dialog_through_action(self, xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuLegend"})) as xDialog:
+      with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuLegend"})) as xDialog:
         left = xDialog.getChild("left")
         right = xDialog.getChild("right")
         top = xDialog.getChild("top")
@@ -61,7 +60,7 @@ class chartLegend(UITestCase):
       xChartMainTop = self.xUITest.getTopFocusWindow()
       xChartMain = xChartMainTop.getChild("chart_window")
       xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-      with guarded.execute_dialog_through_action(self, xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuLegend"})) as xDialog:
+      with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuLegend"})) as xDialog:
         left = xDialog.getChild("left")
         right = xDialog.getChild("right")
         top = xDialog.getChild("top")
@@ -92,7 +91,7 @@ class chartLegend(UITestCase):
       xLegends = xChartMain.getChild("CID/D=0:Legend=")
       xLegends.executeAction("SELECT", tuple())
 
-      with guarded.execute_dialog_through_action(self, xLegends, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog:
+      with self.ui_test.execute_dialog_through_action(xLegends, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog:
         self.assertEqual("4.61", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value'])
         self.assertEqual("1.53", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value'])
 
@@ -100,7 +99,7 @@ class chartLegend(UITestCase):
       xChartMain.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"}))
 
       # Check the position has changed after moving the label using the arrows keys
-      with guarded.execute_dialog_through_action(self, xLegends, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog:
+      with self.ui_test.execute_dialog_through_action(xLegends, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog:
         self.assertEqual("4.51", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value'])
         self.assertEqual("1.43", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value'])
 
diff --git a/sc/qa/uitest/chart/chartTitles.py b/sc/qa/uitest/chart/chartTitles.py
index 84f0878a22e8..c94823387ece 100644
--- a/sc/qa/uitest/chart/chartTitles.py
+++ b/sc/qa/uitest/chart/chartTitles.py
@@ -33,25 +33,22 @@ class chartTitles(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuTitles"}))
-        xDialog = self.xUITest.getTopFocusWindow()
-
-        maintitle = xDialog.getChild("maintitle")
-        subtitle = xDialog.getChild("subtitle")
-        primaryXaxis = xDialog.getChild("primaryXaxis")
-        primaryYaxis = xDialog.getChild("primaryYaxis")
-        secondaryXaxis = xDialog.getChild("secondaryXaxis")
-        secondaryYaxis = xDialog.getChild("secondaryYaxis")
-
-        maintitle.executeAction("TYPE", mkPropertyValues({"TEXT":"A"}))
-        subtitle.executeAction("TYPE", mkPropertyValues({"TEXT":"B"}))
-        primaryXaxis.executeAction("TYPE", mkPropertyValues({"TEXT":"C"}))
-        primaryYaxis.executeAction("TYPE", mkPropertyValues({"TEXT":"D"}))
-        secondaryXaxis.executeAction("TYPE", mkPropertyValues({"TEXT":"E"}))
-        secondaryYaxis.executeAction("TYPE", mkPropertyValues({"TEXT":"F"}))
-
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuTitles"})) as xDialog:
+
+            maintitle = xDialog.getChild("maintitle")
+            subtitle = xDialog.getChild("subtitle")
+            primaryXaxis = xDialog.getChild("primaryXaxis")
+            primaryYaxis = xDialog.getChild("primaryYaxis")
+            secondaryXaxis = xDialog.getChild("secondaryXaxis")
+            secondaryYaxis = xDialog.getChild("secondaryYaxis")
+
+            maintitle.executeAction("TYPE", mkPropertyValues({"TEXT":"A"}))
+            subtitle.executeAction("TYPE", mkPropertyValues({"TEXT":"B"}))
+            primaryXaxis.executeAction("TYPE", mkPropertyValues({"TEXT":"C"}))
+            primaryYaxis.executeAction("TYPE", mkPropertyValues({"TEXT":"D"}))
+            secondaryXaxis.executeAction("TYPE", mkPropertyValues({"TEXT":"E"}))
+            secondaryYaxis.executeAction("TYPE", mkPropertyValues({"TEXT":"F"}))
+
 
         self.assertTrue(document.Sheets[0].Charts[0].getEmbeddedObject().HasMainTitle)
         self.assertTrue(document.Sheets[0].Charts[0].getEmbeddedObject().HasSubTitle)
@@ -68,25 +65,22 @@ class chartTitles(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuTitles"}))
-        xDialog = self.xUITest.getTopFocusWindow()
-
-        maintitle = xDialog.getChild("maintitle")
-        subtitle = xDialog.getChild("subtitle")
-        primaryXaxis = xDialog.getChild("primaryXaxis")
-        primaryYaxis = xDialog.getChild("primaryYaxis")
-        secondaryXaxis = xDialog.getChild("secondaryXaxis")
-        secondaryYaxis = xDialog.getChild("secondaryYaxis")
-
-        self.assertEqual(get_state_as_dict(maintitle)["Text"], "A")
-        self.assertEqual(get_state_as_dict(subtitle)["Text"], "B")
-        self.assertEqual(get_state_as_dict(primaryXaxis)["Text"], "C")
-        self.assertEqual(get_state_as_dict(primaryYaxis)["Text"], "D")
-        self.assertEqual(get_state_as_dict(secondaryXaxis)["Text"], "E")
-        self.assertEqual(get_state_as_dict(secondaryYaxis)["Text"], "F")
-
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "InsertMenuTitles"})) as xDialog:
+
+            maintitle = xDialog.getChild("maintitle")
+            subtitle = xDialog.getChild("subtitle")
+            primaryXaxis = xDialog.getChild("primaryXaxis")
+            primaryYaxis = xDialog.getChild("primaryYaxis")
+            secondaryXaxis = xDialog.getChild("secondaryXaxis")
+            secondaryYaxis = xDialog.getChild("secondaryYaxis")
+
+            self.assertEqual(get_state_as_dict(maintitle)["Text"], "A")
+            self.assertEqual(get_state_as_dict(subtitle)["Text"], "B")
+            self.assertEqual(get_state_as_dict(primaryXaxis)["Text"], "C")
+            self.assertEqual(get_state_as_dict(primaryYaxis)["Text"], "D")
+            self.assertEqual(get_state_as_dict(secondaryXaxis)["Text"], "E")
+            self.assertEqual(get_state_as_dict(secondaryYaxis)["Text"], "F")
+
 
    def test_title_move_with_arrows_keys(self):
 
@@ -105,26 +99,20 @@ class chartTitles(UITestCase):
         xTitle = xChartMain.getChild("CID/Title=")
         xTitle.executeAction("SELECT", tuple())
 
-        self.ui_test.execute_dialog_through_action(xTitle, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"}))
+        with self.ui_test.execute_dialog_through_action(xTitle, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog:
 
-        xDialog = self.xUITest.getTopFocusWindow()
-        self.assertEqual("3.52", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value'])
-        self.assertEqual("0.3", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value'])
+            self.assertEqual("3.52", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value'])
+            self.assertEqual("0.3", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value'])
 
-        xOkBtn = xDialog.getChild("ok")
-        xOkBtn.executeAction("CLICK", tuple())
 
         xChartMain.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
         xChartMain.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"}))
 
-        self.ui_test.execute_dialog_through_action(xTitle, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"}))
+        with self.ui_test.execute_dialog_through_action(xTitle, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog:
 
-        # Check the position has changed after moving the title using the arrows keys
-        xDialog = self.xUITest.getTopFocusWindow()
-        self.assertEqual("3.42", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value'])
-        self.assertEqual("0.2", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value'])
+            # Check the position has changed after moving the title using the arrows keys
+            self.assertEqual("3.42", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value'])
+            self.assertEqual("0.2", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value'])
 
-        xOkBtn = xDialog.getChild("ok")
-        xOkBtn.executeAction("CLICK", tuple())
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/chart/chartWall.py b/sc/qa/uitest/chart/chartWall.py
index 485ce8d2090f..600bb8e6d362 100644
--- a/sc/qa/uitest/chart/chartWall.py
+++ b/sc/qa/uitest/chart/chartWall.py
@@ -34,20 +34,17 @@ class chartWall(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramWall"}))
-        xDialog = self.xUITest.getTopFocusWindow()
-        #Click on tab "Borders".
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramWall"})) as xDialog:
+            #Click on tab "Borders".
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
 
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
 
-        xWidth.executeAction("UP", tuple())
-        transparency.executeAction("UP", tuple())
+            xWidth.executeAction("UP", tuple())
+            transparency.executeAction("UP", tuple())
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         self.assertEqual(xWall.LineWidth, 100)
         self.assertEqual(xWall.LineTransparence, 5)
@@ -60,48 +57,45 @@ class chartWall(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramWall"}))
-        xDialog = self.xUITest.getTopFocusWindow()
-
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
-
-        self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
-        self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
-
-        self.assertEqual(xWall.LineWidth, 100)
-        self.assertEqual(xWall.LineTransparence, 5)
-        self.assertEqual(hex(xWall.FillColor), '0xe6e6e6')
-        self.assertEqual(xWall.FillTransparence, 0)
-
-        #Click on tab "Area"
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "1")
-
-        btncolor = xDialog.getChild("btncolor")
-        btncolor.executeAction("CLICK", tuple())
-
-        rCustom = xDialog.getChild("R_custom")
-        gCustom = xDialog.getChild("G_custom")
-        bCustom = xDialog.getChild("B_custom")
-
-        rCustom.executeAction("CLEAR", tuple())
-        rCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"35"}))
-        rCustom.executeAction("UP", tuple())
-        rCustom.executeAction("DOWN", tuple())  #without this save data doesn't works
-        self.assertEqual(get_state_as_dict(rCustom)["Text"], "35")
-        gCustom.executeAction("CLEAR", tuple())
-        gCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"169"}))
-        gCustom.executeAction("UP", tuple())
-        gCustom.executeAction("DOWN", tuple())  #without this save data doesn't works
-        bCustom.executeAction("CLEAR", tuple())
-        bCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"211"}))
-        bCustom.executeAction("UP", tuple())
-        bCustom.executeAction("DOWN", tuple())  #without this save data doesn't works
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramWall"})) as xDialog:
+
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+
+            self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
+            self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
+
+            self.assertEqual(xWall.LineWidth, 100)
+            self.assertEqual(xWall.LineTransparence, 5)
+            self.assertEqual(hex(xWall.FillColor), '0xe6e6e6')
+            self.assertEqual(xWall.FillTransparence, 0)
+
+            #Click on tab "Area"
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "1")
+
+            btncolor = xDialog.getChild("btncolor")
+            btncolor.executeAction("CLICK", tuple())
+
+            rCustom = xDialog.getChild("R_custom")
+            gCustom = xDialog.getChild("G_custom")
+            bCustom = xDialog.getChild("B_custom")
+
+            rCustom.executeAction("CLEAR", tuple())
+            rCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"35"}))
+            rCustom.executeAction("UP", tuple())
+            rCustom.executeAction("DOWN", tuple())  #without this save data doesn't works
+            self.assertEqual(get_state_as_dict(rCustom)["Text"], "35")
+            gCustom.executeAction("CLEAR", tuple())
+            gCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"169"}))
+            gCustom.executeAction("UP", tuple())
+            gCustom.executeAction("DOWN", tuple())  #without this save data doesn't works
+            bCustom.executeAction("CLEAR", tuple())
+            bCustom.executeAction("TYPE", mkPropertyValues({"TEXT":"211"}))
+            bCustom.executeAction("UP", tuple())
+            bCustom.executeAction("DOWN", tuple())  #without this save data doesn't works
 
         self.assertEqual(xWall.LineWidth, 100)
         self.assertEqual(xWall.LineTransparence, 5)
@@ -114,35 +108,32 @@ class chartWall(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramWall"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramWall"})) as xDialog:
 
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "1")
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "1")
 
-        rCustom = xDialog.getChild("R_custom")
-        gCustom = xDialog.getChild("G_custom")
-        bCustom = xDialog.getChild("B_custom")
+            rCustom = xDialog.getChild("R_custom")
+            gCustom = xDialog.getChild("G_custom")
+            bCustom = xDialog.getChild("B_custom")
 
-        self.assertEqual(get_state_as_dict(rCustom)["Text"], "35")
-        self.assertEqual(get_state_as_dict(gCustom)["Text"], "169")
-        self.assertEqual(get_state_as_dict(bCustom)["Text"], "211")
+            self.assertEqual(get_state_as_dict(rCustom)["Text"], "35")
+            self.assertEqual(get_state_as_dict(gCustom)["Text"], "169")
+            self.assertEqual(get_state_as_dict(bCustom)["Text"], "211")
 
-        self.assertEqual(xWall.LineWidth, 100)
-        self.assertEqual(xWall.LineTransparence, 5)
-        self.assertEqual(hex(xWall.FillColor), '0x23a9d3')
-        self.assertEqual(xWall.FillTransparence, 0)
+            self.assertEqual(xWall.LineWidth, 100)
+            self.assertEqual(xWall.LineTransparence, 5)
+            self.assertEqual(hex(xWall.FillColor), '0x23a9d3')
+            self.assertEqual(xWall.FillTransparence, 0)
 
-        #change tab "Transparency"
-        select_pos(tabcontrol, "2")
-        transparency = xDialog.getChild("RBT_TRANS_LINEAR")
-        transparencyPercent = xDialog.getChild("MTR_TRANSPARENT")  #51%
+            #change tab "Transparency"
+            select_pos(tabcontrol, "2")
+            transparency = xDialog.getChild("RBT_TRANS_LINEAR")
+            transparencyPercent = xDialog.getChild("MTR_TRANSPARENT")  #51%
 
-        transparency.executeAction("CLICK", tuple())
-        transparencyPercent.executeAction("UP", tuple())
+            transparency.executeAction("CLICK", tuple())
+            transparencyPercent.executeAction("UP", tuple())
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         self.assertEqual(xWall.LineWidth, 100)
         self.assertEqual(xWall.LineTransparence, 5)
@@ -155,25 +146,22 @@ class chartWall(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramWall"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramWall"})) as xDialog:
 
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "2")
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "2")
 
-        transparency = xDialog.getChild("RBT_TRANS_LINEAR")
-        transparencyPercent = xDialog.getChild("MTR_TRANSPARENT")  #51%
+            transparency = xDialog.getChild("RBT_TRANS_LINEAR")
+            transparencyPercent = xDialog.getChild("MTR_TRANSPARENT")  #51%
 
-        self.assertEqual(get_state_as_dict(transparency)["Checked"], "true")
-        self.assertEqual(get_state_as_dict(transparencyPercent)["Text"], "51%")
+            self.assertEqual(get_state_as_dict(transparency)["Checked"], "true")
+            self.assertEqual(get_state_as_dict(transparencyPercent)["Text"], "51%")
 
-        self.assertEqual(xWall.LineWidth, 100)
-        self.assertEqual(xWall.LineTransparence, 5)
-        self.assertEqual(hex(xWall.FillColor), '0x23a9d3')
-        self.assertEqual(xWall.FillTransparence, 51)
+            self.assertEqual(xWall.LineWidth, 100)
+            self.assertEqual(xWall.LineTransparence, 5)
+            self.assertEqual(hex(xWall.FillColor), '0x23a9d3')
+            self.assertEqual(xWall.FillTransparence, 51)
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         self.assertEqual(xWall.LineWidth, 100)
         self.assertEqual(xWall.LineTransparence, 5)
diff --git a/sc/qa/uitest/chart/chartXAxis.py b/sc/qa/uitest/chart/chartXAxis.py
index 15adb54b64b0..085bee88bb8f 100644
--- a/sc/qa/uitest/chart/chartXAxis.py
+++ b/sc/qa/uitest/chart/chartXAxis.py
@@ -29,36 +29,33 @@ class chartXAxis(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramAxisX"}))  # X Axis...
-        xDialog = self.xUITest.getTopFocusWindow()
-        #Click on tab "Scale".
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
-
-        reverseDirection = xDialog.getChild("CBX_REVERSE")
-        logarithmicScale = xDialog.getChild("CBX_LOGARITHM")
-        autoMinimum = xDialog.getChild("CBX_AUTO_MIN")
-        autoMaximum = xDialog.getChild("CBX_AUTO_MAX")
-        majorInterval = xDialog.getChild("CBX_AUTO_STEP_MAIN")
-        minorInterval = xDialog.getChild("CBX_AUTO_STEP_HELP")
-        minimum = xDialog.getChild("EDT_MIN")
-        maximum = xDialog.getChild("EDT_MAX")
-        major = xDialog.getChild("EDT_STEP_MAIN")
-        minor = xDialog.getChild("MT_STEPHELP")
-
-        reverseDirection.executeAction("CLICK", tuple())
-        logarithmicScale.executeAction("CLICK", tuple())
-        autoMinimum.executeAction("CLICK", tuple())
-        autoMaximum.executeAction("CLICK", tuple())
-        majorInterval.executeAction("CLICK", tuple())
-        minorInterval.executeAction("CLICK", tuple())
-
-        minimum.executeAction("DOWN", tuple()) #10.12.2017
-        maximum.executeAction("DOWN", tuple()) #29.04.2018
-        major.executeAction("DOWN", tuple())   #19
-        minor.executeAction("UP", tuple())  #3
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramAxisX"})) as xDialog:
+            #Click on tab "Scale".
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
+
+            reverseDirection = xDialog.getChild("CBX_REVERSE")
+            logarithmicScale = xDialog.getChild("CBX_LOGARITHM")
+            autoMinimum = xDialog.getChild("CBX_AUTO_MIN")
+            autoMaximum = xDialog.getChild("CBX_AUTO_MAX")
+            majorInterval = xDialog.getChild("CBX_AUTO_STEP_MAIN")
+            minorInterval = xDialog.getChild("CBX_AUTO_STEP_HELP")
+            minimum = xDialog.getChild("EDT_MIN")
+            maximum = xDialog.getChild("EDT_MAX")
+            major = xDialog.getChild("EDT_STEP_MAIN")
+            minor = xDialog.getChild("MT_STEPHELP")
+
+            reverseDirection.executeAction("CLICK", tuple())
+            logarithmicScale.executeAction("CLICK", tuple())
+            autoMinimum.executeAction("CLICK", tuple())
+            autoMaximum.executeAction("CLICK", tuple())
+            majorInterval.executeAction("CLICK", tuple())
+            minorInterval.executeAction("CLICK", tuple())
+
+            minimum.executeAction("DOWN", tuple()) #10.12.2017
+            maximum.executeAction("DOWN", tuple()) #29.04.2018
+            major.executeAction("DOWN", tuple())   #19
+            minor.executeAction("UP", tuple())  #3
 
         #reopen and verify
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -66,57 +63,54 @@ class chartXAxis(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramAxisX"}))
-        xDialog = self.xUITest.getTopFocusWindow()
-        #Click on tab "Scale".
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "0")
-
-        reverseDirection = xDialog.getChild("CBX_REVERSE")
-        logarithmicScale = xDialog.getChild("CBX_LOGARITHM")
-        autoMinimum = xDialog.getChild("CBX_AUTO_MIN")
-        autoMaximum = xDialog.getChild("CBX_AUTO_MAX")
-        majorInterval = xDialog.getChild("CBX_AUTO_STEP_MAIN")
-        minorInterval = xDialog.getChild("CBX_AUTO_STEP_HELP")
-        minimum = xDialog.getChild("EDT_MIN")
-        maximum = xDialog.getChild("EDT_MAX")
-        major = xDialog.getChild("EDT_STEP_MAIN")
-        minor = xDialog.getChild("MT_STEPHELP")
-
-        self.assertEqual(get_state_as_dict(reverseDirection)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(logarithmicScale)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(autoMinimum)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(autoMaximum)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(majorInterval)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(minorInterval)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(minimum)["Text"], "10.12.2017")
-        self.assertEqual(get_state_as_dict(maximum)["Text"], "29.04.2018")
-        self.assertEqual(get_state_as_dict(major)["Text"], "19")
-        self.assertEqual(get_state_as_dict(minor)["Text"], "3")
-
-        #Click on tab "positioning".
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "1")
-
-        crossAxis = xDialog.getChild("LB_CROSSES_OTHER_AXIS_AT")
-        crossAxisValue = xDialog.getChild("EDT_CROSSES_OTHER_AXIS_AT") #only available when crossAxis = Value
-        placeLabels = xDialog.getChild("LB_PLACE_LABELS")
-        innerMajorTick = xDialog.getChild("CB_TICKS_INNER")
-        outerMajorTick = xDialog.getChild("CB_TICKS_OUTER")
-        innerMinorTick = xDialog.getChild("CB_MINOR_INNER")
-        outerMinorTick = xDialog.getChild("CB_MINOR_OUTER")
-        placeMarks = xDialog.getChild("LB_PLACE_TICKS")
-
-        select_by_text(crossAxis, "Start")
-        select_by_text(placeLabels, "Outside end")
-        innerMajorTick.executeAction("CLICK", tuple())
-        outerMajorTick.executeAction("CLICK", tuple())
-        innerMinorTick.executeAction("CLICK", tuple())
-        outerMinorTick.executeAction("CLICK", tuple())
-        select_by_text(placeMarks, "At axis")
-
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramAxisX"})) as xDialog:
+            #Click on tab "Scale".
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "0")
+
+            reverseDirection = xDialog.getChild("CBX_REVERSE")
+            logarithmicScale = xDialog.getChild("CBX_LOGARITHM")
+            autoMinimum = xDialog.getChild("CBX_AUTO_MIN")
+            autoMaximum = xDialog.getChild("CBX_AUTO_MAX")
+            majorInterval = xDialog.getChild("CBX_AUTO_STEP_MAIN")
+            minorInterval = xDialog.getChild("CBX_AUTO_STEP_HELP")
+            minimum = xDialog.getChild("EDT_MIN")
+            maximum = xDialog.getChild("EDT_MAX")
+            major = xDialog.getChild("EDT_STEP_MAIN")
+            minor = xDialog.getChild("MT_STEPHELP")
+
+            self.assertEqual(get_state_as_dict(reverseDirection)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(logarithmicScale)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(autoMinimum)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(autoMaximum)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(majorInterval)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(minorInterval)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(minimum)["Text"], "10.12.2017")
+            self.assertEqual(get_state_as_dict(maximum)["Text"], "29.04.2018")
+            self.assertEqual(get_state_as_dict(major)["Text"], "19")
+            self.assertEqual(get_state_as_dict(minor)["Text"], "3")
+
+            #Click on tab "positioning".
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "1")
+
+            crossAxis = xDialog.getChild("LB_CROSSES_OTHER_AXIS_AT")
+            crossAxisValue = xDialog.getChild("EDT_CROSSES_OTHER_AXIS_AT") #only available when crossAxis = Value
+            placeLabels = xDialog.getChild("LB_PLACE_LABELS")
+            innerMajorTick = xDialog.getChild("CB_TICKS_INNER")
+            outerMajorTick = xDialog.getChild("CB_TICKS_OUTER")
+            innerMinorTick = xDialog.getChild("CB_MINOR_INNER")
+            outerMinorTick = xDialog.getChild("CB_MINOR_OUTER")
+            placeMarks = xDialog.getChild("LB_PLACE_TICKS")
+
+            select_by_text(crossAxis, "Start")
+            select_by_text(placeLabels, "Outside end")
+            innerMajorTick.executeAction("CLICK", tuple())
+            outerMajorTick.executeAction("CLICK", tuple())
+            innerMinorTick.executeAction("CLICK", tuple())
+            outerMinorTick.executeAction("CLICK", tuple())
+            select_by_text(placeMarks, "At axis")
+
 
         #reopen and verify tab "positioning".
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -124,34 +118,31 @@ class chartXAxis(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramAxisX"}))
-        xDialog = self.xUITest.getTopFocusWindow()
-
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "1")
-
-        crossAxis = xDialog.getChild("LB_CROSSES_OTHER_AXIS_AT")
-        crossAxisValue = xDialog.getChild("EDT_CROSSES_OTHER_AXIS_AT") #only available when crossAxis = Value
-        placeLabels = xDialog.getChild("LB_PLACE_LABELS")
-        innerMajorTick = xDialog.getChild("CB_TICKS_INNER")
-        outerMajorTick = xDialog.getChild("CB_TICKS_OUTER")
-        innerMinorTick = xDialog.getChild("CB_MINOR_INNER")
-        outerMinorTick = xDialog.getChild("CB_MINOR_OUTER")
-        placeMarks = xDialog.getChild("LB_PLACE_TICKS")
-
-        self.assertEqual(get_state_as_dict(crossAxis)["SelectEntryText"], "Start")
-        self.assertEqual(get_state_as_dict(placeLabels)["SelectEntryText"], "Outside end")
-        self.assertEqual(get_state_as_dict(innerMajorTick)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(outerMajorTick)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(innerMinorTick)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(outerMinorTick)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(placeMarks)["SelectEntryText"], "At axis")
-        #change tab "positioning".
-        select_by_text(crossAxis, "Value")
-        crossAxisValue.executeAction("UP", tuple())  #1
-
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramAxisX"})) as xDialog:
+
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "1")
+
+            crossAxis = xDialog.getChild("LB_CROSSES_OTHER_AXIS_AT")
+            crossAxisValue = xDialog.getChild("EDT_CROSSES_OTHER_AXIS_AT") #only available when crossAxis = Value
+            placeLabels = xDialog.getChild("LB_PLACE_LABELS")
+            innerMajorTick = xDialog.getChild("CB_TICKS_INNER")
+            outerMajorTick = xDialog.getChild("CB_TICKS_OUTER")
+            innerMinorTick = xDialog.getChild("CB_MINOR_INNER")
+            outerMinorTick = xDialog.getChild("CB_MINOR_OUTER")
+            placeMarks = xDialog.getChild("LB_PLACE_TICKS")
+
+            self.assertEqual(get_state_as_dict(crossAxis)["SelectEntryText"], "Start")
+            self.assertEqual(get_state_as_dict(placeLabels)["SelectEntryText"], "Outside end")
+            self.assertEqual(get_state_as_dict(innerMajorTick)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(outerMajorTick)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(innerMinorTick)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(outerMinorTick)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(placeMarks)["SelectEntryText"], "At axis")
+            #change tab "positioning".
+            select_by_text(crossAxis, "Value")
+            crossAxisValue.executeAction("UP", tuple())  #1
+
 
         #reopen and verify tab "positioning".
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -159,40 +150,37 @@ class chartXAxis(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramAxisX"}))
-        xDialog = self.xUITest.getTopFocusWindow()
-
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "1")
-
-        crossAxis = xDialog.getChild("LB_CROSSES_OTHER_AXIS_AT")
-        crossAxisValue = xDialog.getChild("EDT_CROSSES_OTHER_AXIS_AT") #only available when crossAxis = Value
-        placeLabels = xDialog.getChild("LB_PLACE_LABELS")
-        innerMajorTick = xDialog.getChild("CB_TICKS_INNER")
-        outerMajorTick = xDialog.getChild("CB_TICKS_OUTER")
-        innerMinorTick = xDialog.getChild("CB_MINOR_INNER")
-        outerMinorTick = xDialog.getChild("CB_MINOR_OUTER")
-        placeMarks = xDialog.getChild("LB_PLACE_TICKS")
-
-        self.assertEqual(get_state_as_dict(crossAxis)["SelectEntryText"], "Value")
-        self.assertEqual(get_state_as_dict(crossAxisValue)["Text"], "1")
-        self.assertEqual(get_state_as_dict(placeLabels)["SelectEntryText"], "Outside end")
-        self.assertEqual(get_state_as_dict(innerMajorTick)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(outerMajorTick)["Selected"], "false")
-        self.assertEqual(get_state_as_dict(innerMinorTick)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(outerMinorTick)["Selected"], "true")
-        self.assertEqual(get_state_as_dict(placeMarks)["SelectEntryText"], "At axis")
-        #change tab "Line".
-        select_pos(tabcontrol, "2")
-
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
-
-        xWidth.executeAction("UP", tuple())
-        transparency.executeAction("UP", tuple())
-
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramAxisX"})) as xDialog:
+
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "1")
+
+            crossAxis = xDialog.getChild("LB_CROSSES_OTHER_AXIS_AT")
+            crossAxisValue = xDialog.getChild("EDT_CROSSES_OTHER_AXIS_AT") #only available when crossAxis = Value
+            placeLabels = xDialog.getChild("LB_PLACE_LABELS")
+            innerMajorTick = xDialog.getChild("CB_TICKS_INNER")
+            outerMajorTick = xDialog.getChild("CB_TICKS_OUTER")
+            innerMinorTick = xDialog.getChild("CB_MINOR_INNER")
+            outerMinorTick = xDialog.getChild("CB_MINOR_OUTER")
+            placeMarks = xDialog.getChild("LB_PLACE_TICKS")
+
+            self.assertEqual(get_state_as_dict(crossAxis)["SelectEntryText"], "Value")
+            self.assertEqual(get_state_as_dict(crossAxisValue)["Text"], "1")
+            self.assertEqual(get_state_as_dict(placeLabels)["SelectEntryText"], "Outside end")
+            self.assertEqual(get_state_as_dict(innerMajorTick)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(outerMajorTick)["Selected"], "false")
+            self.assertEqual(get_state_as_dict(innerMinorTick)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(outerMinorTick)["Selected"], "true")
+            self.assertEqual(get_state_as_dict(placeMarks)["SelectEntryText"], "At axis")
+            #change tab "Line".
+            select_pos(tabcontrol, "2")
+
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+
+            xWidth.executeAction("UP", tuple())
+            transparency.executeAction("UP", tuple())
+
 
         #reopen and verify tab "Line".
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -200,36 +188,33 @@ class chartXAxis(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramAxisX"}))
-        xDialog = self.xUITest.getTopFocusWindow()
+        with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramAxisX"})) as xDialog:
 
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "2")
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "2")
 
-        xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
-        transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
+            xWidth = xDialog.getChild("MTR_FLD_LINE_WIDTH")
+            transparency = xDialog.getChild("MTR_LINE_TRANSPARENT")
 
-        self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
-        self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
+            self.assertEqual(get_state_as_dict(xWidth)["Text"], "0.10 cm")
+            self.assertEqual(get_state_as_dict(transparency)["Text"], "5%")
 
-        #change tab "Label"
-        tabcontrol = xDialog.getChild("tabcontrol")
-        select_pos(tabcontrol, "3")
+            #change tab "Label"
+            tabcontrol = xDialog.getChild("tabcontrol")
+            select_pos(tabcontrol, "3")
 
-        tile = xDialog.getChild("tile")
-        overlapCB = xDialog.getChild("overlapCB")
-        breakCB = xDialog.getChild("breakCB")
-        stackedCB = xDialog.getChild("stackedCB")
-        textdirLB = xDialog.getChild("textdirLB")
+            tile = xDialog.getChild("tile")
+            overlapCB = xDialog.getChild("overlapCB")
+            breakCB = xDialog.getChild("breakCB")
+            stackedCB = xDialog.getChild("stackedCB")
+            textdirLB = xDialog.getChild("textdirLB")
 
-        tile.executeAction("CLICK", tuple())
-        overlapCB.executeAction("CLICK", tuple())
-        breakCB.executeAction("CLICK", tuple())
-        stackedCB.executeAction("CLICK", tuple())
-        select_by_text(textdirLB, "Right-to-left")
+            tile.executeAction("CLICK", tuple())
+            overlapCB.executeAction("CLICK", tuple())
+            breakCB.executeAction("CLICK", tuple())
+            stackedCB.executeAction("CLICK", tuple())
+            select_by_text(textdirLB, "Right-to-left")
 
-        xOKBtn = xDialog.getChild("ok")
-        self.ui_test.close_dialog_through_button(xOKBtn)
 
         #reopen and verify tab "Label".
         gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
@@ -237,25 +222,22 @@ class chartXAxis(UITestCase):
         xChartMainTop = self.xUITest.getTopFocusWindow()
         xChartMain = xChartMainTop.getChild("chart_window")
         xSeriesObj =  xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
-        self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "DiagramAxisX"}))
-        xDialog = self.xUITest.getTopFocusWindow()
-

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list