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

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 30 11:18:10 UTC 2021


 sw/qa/uitest/chapterNumbering/chapterNumbering.py       |  114 --
 sw/qa/uitest/chapterNumbering/tdf140528.py              |   42 
 sw/qa/uitest/chart/tdf138556.py                         |   55 
 sw/qa/uitest/classification/classification.py           |  216 +--
 sw/qa/uitest/findBar/findbar.py                         |   79 -
 sw/qa/uitest/findBar/tdf136941.py                       |   65 -
 sw/qa/uitest/findBar/tdf138232.py                       |   45 
 sw/qa/uitest/findBar/tdf88608.py                        |   51 
 sw/qa/uitest/findReplace/findReplace.py                 |   78 -
 sw/qa/uitest/findReplace/tdf106099.py                   |   46 
 sw/qa/uitest/findReplace/tdf119462.py                   |   44 
 sw/qa/uitest/librelogo/run.py                           |   80 -
 sw/qa/uitest/macro_tests/tdf124413.py                   |   55 
 sw/qa/uitest/macro_tests/tdf64690.py                    |   73 -
 sw/qa/uitest/navigator/tdf137274.py                     |   61 -
 sw/qa/uitest/navigator/tdf140257.py                     |  114 --
 sw/qa/uitest/options/optionsDialog.py                   |   50 
 sw/qa/uitest/options/tdf131581.py                       |   27 
 sw/qa/uitest/options/tdf78133.py                        |   48 
 sw/qa/uitest/sidebar/stylesSidebar.py                   |   77 -
 sw/qa/uitest/sidebar/tdf133189.py                       |  119 +-
 sw/qa/uitest/sidebar/tdf135590.py                       |   77 -
 sw/qa/uitest/styleInspector/tdf137105.py                |   48 
 sw/qa/uitest/styleInspector/tdf137513.py                |   65 -
 sw/qa/uitest/table/insertTableDialog.py                 |   66 -
 sw/qa/uitest/table/sheetToTable.py                      |   20 
 sw/qa/uitest/table/tdf115026.py                         |   21 
 sw/qa/uitest/table/tdf116737.py                         |   42 
 sw/qa/uitest/table/tdf128593.py                         |   33 
 sw/qa/uitest/table/textToTable.py                       |   38 
 sw/qa/uitest/ui/fmtui/fmtui.py                          |   28 
 sw/qa/uitest/ui/index/index.py                          |   70 -
 sw/qa/uitest/writer_tests/comments.py                   |  240 ++--
 sw/qa/uitest/writer_tests/insertCaption.py              |   58 -
 sw/qa/uitest/writer_tests/tdf134734.py                  |  114 --
 sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py |   23 
 sw/qa/uitest/writer_tests/tdf53460.py                   |  102 -
 sw/qa/uitest/writer_tests/tdf78068.py                   |   22 
 sw/qa/uitest/writer_tests/tdf93068.py                   |   46 
 sw/qa/uitest/writer_tests/trackedChanges.py             |  191 +--
 sw/qa/uitest/writer_tests/watermark.py                  |   48 
 sw/qa/uitest/writer_tests/wordCount.py                  |  304 ++---
 sw/qa/uitest/writer_tests2/asianPhoneticGuide.py        |   40 
 sw/qa/uitest/writer_tests2/bookmark.py                  |  105 -
 sw/qa/uitest/writer_tests2/deleteAllComments.py         |   42 
 sw/qa/uitest/writer_tests2/documentProperties.py        |  139 +-
 sw/qa/uitest/writer_tests2/exchangeDatabase.py          |   36 
 sw/qa/uitest/writer_tests2/fontworks.py                 |   35 
 sw/qa/uitest/writer_tests2/formatBulletsNumbering.py    |  452 +++-----
 sw/qa/uitest/writer_tests2/formatCharacter.py           |  400 +++----
 sw/qa/uitest/writer_tests2/formatParagraph.py           |  902 +++++++---------
 sw/qa/uitest/writer_tests2/horizontalLine.py            |   27 
 sw/qa/uitest/writer_tests2/insertFootnote.py            |   34 
 sw/qa/uitest/writer_tests2/pasteSpecial.py              |   28 
 sw/qa/uitest/writer_tests2/tdf116474.py                 |   58 -
 sw/qa/uitest/writer_tests3/autoredactDialog.py          |  186 +--
 sw/qa/uitest/writer_tests3/customizeDialog.py           |  123 +-
 sw/qa/uitest/writer_tests3/hyperlinkdialog.py           |   93 -
 sw/qa/uitest/writer_tests3/insertEndnote.py             |   34 
 sw/qa/uitest/writer_tests3/insertEnvelope.py            |   42 
 sw/qa/uitest/writer_tests3/insertFootEndnote.py         |   68 -
 sw/qa/uitest/writer_tests3/insertPageFooter.py          |   27 
 sw/qa/uitest/writer_tests3/insertQrCodeGen.py           |   76 -
 sw/qa/uitest/writer_tests3/insertSignatureLine.py       |  136 +-
 sw/qa/uitest/writer_tests3/lineNumbering.py             |  126 +-
 sw/qa/uitest/writer_tests3/pageDialog.py                |  113 --
 sw/qa/uitest/writer_tests3/sort.py                      |   86 -
 sw/qa/uitest/writer_tests3/specialCharacter.py          |   92 -
 sw/qa/uitest/writer_tests3/tdf79236.py                  |  134 +-
 sw/qa/uitest/writer_tests4/insertBreakDialog.py         |   50 
 sw/qa/uitest/writer_tests4/insertPageHeader.py          |   27 
 sw/qa/uitest/writer_tests4/spellDialog.py               |   74 -
 sw/qa/uitest/writer_tests4/start.py                     |   30 
 sw/qa/uitest/writer_tests4/tdf113252.py                 |   30 
 sw/qa/uitest/writer_tests4/tdf115572.py                 |   86 -
 sw/qa/uitest/writer_tests4/tdf115573.py                 |  164 +-
 sw/qa/uitest/writer_tests4/tdf51352.py                  |   58 -
 sw/qa/uitest/writer_tests4/tdf92611.py                  |    7 
 sw/qa/uitest/writer_tests5/about_test.py                |    7 
 sw/qa/uitest/writer_tests5/autocorrectOptions.py        |  160 +-
 sw/qa/uitest/writer_tests5/columns.py                   |   52 
 sw/qa/uitest/writer_tests5/tdf107494.py                 |  116 --
 sw/qa/uitest/writer_tests5/tdf122045.py                 |   28 
 sw/qa/uitest/writer_tests5/tdf122722.py                 |   84 -
 sw/qa/uitest/writer_tests5/tdf123378.py                 |   16 
 sw/qa/uitest/writer_tests5/tdf123446.py                 |   48 
 sw/qa/uitest/writer_tests5/titlePage.py                 |   30 
 sw/qa/uitest/writer_tests5/xwindow.py                   |  188 +--
 sw/qa/uitest/writer_tests5/zoom.py                      |  126 +-
 sw/qa/uitest/writer_tests6/infobar.py                   |   59 -
 sw/qa/uitest/writer_tests6/tdf107847.py                 |   32 
 sw/qa/uitest/writer_tests6/tdf118883.py                 |   23 
 sw/qa/uitest/writer_tests6/tdf125104.py                 |   78 -
 sw/qa/uitest/writer_tests6/tdf126168.py                 |   50 
 sw/qa/uitest/writer_tests6/tdf128431.py                 |   34 
 sw/qa/uitest/writer_tests6/tdf131041.py                 |   34 
 sw/qa/uitest/writer_tests6/tdf44837.py                  |   54 
 sw/qa/uitest/writer_tests7/tdf109083.py                 |   83 -
 sw/qa/uitest/writer_tests7/tdf115853.py                 |   27 
 sw/qa/uitest/writer_tests7/tdf119661.py                 |   84 -
 sw/qa/uitest/writer_tests7/tdf133348.py                 |   66 -
 sw/qa/uitest/writer_tests7/tdf140731.py                 |   80 -
 sw/qa/uitest/writer_tests7/tdf140863.py                 |   58 -
 sw/qa/uitest/writer_tests7/tdf90401.py                  |    1 
 104 files changed, 4347 insertions(+), 4626 deletions(-)

New commits:
commit adf59322c651e8e6740a8d97d963dcf0972bdc54
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Wed Jun 30 09:50:25 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Wed Jun 30 13:17:33 2021 +0200

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

diff --git a/sw/qa/uitest/chapterNumbering/chapterNumbering.py b/sw/qa/uitest/chapterNumbering/chapterNumbering.py
index 6c34a722c833..c1fe43f7caab 100644
--- a/sw/qa/uitest/chapterNumbering/chapterNumbering.py
+++ b/sw/qa/uitest/chapterNumbering/chapterNumbering.py
@@ -17,69 +17,67 @@ from uitest.uihelper.common import change_measurement_unit
 class WriterChapterNumbering(UITestCase):
 
     def test_chapter_numbering_dialog(self):
-        self.ui_test.create_doc_in_start_center("writer")
-        document = self.ui_test.get_component()
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
 
-        change_measurement_unit(self, "Millimeter")
+            change_measurement_unit(self, "Millimeter")
 
-        with self.ui_test.execute_dialog_through_command(".uno:ChapterNumberingDialog") as xDialog:
-            xstyle = xDialog.getChild("style")
-            xnumbering = xDialog.getChild("numbering")
-            xcharstyle = xDialog.getChild("charstyle")
-            xprefix = xDialog.getChild("prefix")
-            xsuffix = xDialog.getChild("suffix")
-            xstartat = xDialog.getChild("startat")
-            xtab = xDialog.getChild("tabcontrol")
-            #second tab
-            xalignedatmf = xDialog.getChild("alignedatmf")
-            xnum2alignlb = xDialog.getChild("num2alignlb")
-            xnumfollowedbylb = xDialog.getChild("numfollowedbylb")
-            xatmf = xDialog.getChild("atmf")
-            xindentatmf = xDialog.getChild("indentatmf")
-            select_pos(xtab, "0") #first tab
-            select_by_text(xstyle, "Heading")
-            select_by_text(xnumbering, "1, 2, 3, ...")
-            select_by_text(xcharstyle, "Bullets")
-            xprefix.executeAction("TYPE", mkPropertyValues({"TEXT":"A"}))
-            xsuffix.executeAction("TYPE", mkPropertyValues({"TEXT":"B"}))
-            xstartat.executeAction("UP", tuple())
+            with self.ui_test.execute_dialog_through_command(".uno:ChapterNumberingDialog") as xDialog:
+                xstyle = xDialog.getChild("style")
+                xnumbering = xDialog.getChild("numbering")
+                xcharstyle = xDialog.getChild("charstyle")
+                xprefix = xDialog.getChild("prefix")
+                xsuffix = xDialog.getChild("suffix")
+                xstartat = xDialog.getChild("startat")
+                xtab = xDialog.getChild("tabcontrol")
+                #second tab
+                xalignedatmf = xDialog.getChild("alignedatmf")
+                xnum2alignlb = xDialog.getChild("num2alignlb")
+                xnumfollowedbylb = xDialog.getChild("numfollowedbylb")
+                xatmf = xDialog.getChild("atmf")
+                xindentatmf = xDialog.getChild("indentatmf")
+                select_pos(xtab, "0") #first tab
+                select_by_text(xstyle, "Heading")
+                select_by_text(xnumbering, "1, 2, 3, ...")
+                select_by_text(xcharstyle, "Bullets")
+                xprefix.executeAction("TYPE", mkPropertyValues({"TEXT":"A"}))
+                xsuffix.executeAction("TYPE", mkPropertyValues({"TEXT":"B"}))
+                xstartat.executeAction("UP", tuple())
 
-            select_pos(xtab, "1") #second tab Position
-            xalignedatmf.executeAction("UP", tuple())
-            select_by_text(xnum2alignlb, "Centered")
-            select_by_text(xnumfollowedbylb, "Tab stop")
-            xatmf.executeAction("UP", tuple())
-            xindentatmf.executeAction("UP", tuple())
+                select_pos(xtab, "1") #second tab Position
+                xalignedatmf.executeAction("UP", tuple())
+                select_by_text(xnum2alignlb, "Centered")
+                select_by_text(xnumfollowedbylb, "Tab stop")
+                xatmf.executeAction("UP", tuple())
+                xindentatmf.executeAction("UP", tuple())
 
 
-        with self.ui_test.execute_dialog_through_command(".uno:ChapterNumberingDialog", close_button="cancel") as xDialog:
+            with self.ui_test.execute_dialog_through_command(".uno:ChapterNumberingDialog", close_button="cancel") as xDialog:
 
-            xstyle = xDialog.getChild("style")
-            xnumbering = xDialog.getChild("numbering")
-            xcharstyle = xDialog.getChild("charstyle")
-            xprefix = xDialog.getChild("prefix")
-            xsuffix = xDialog.getChild("suffix")
-            xstartat = xDialog.getChild("startat")
-            xtab = xDialog.getChild("tabcontrol")
-            #second tab
-            xalignedatmf = xDialog.getChild("alignedatmf")
-            xnum2alignlb = xDialog.getChild("num2alignlb")
-            xnumfollowedbylb = xDialog.getChild("numfollowedbylb")
-            xatmf = xDialog.getChild("atmf")
-            xindentatmf = xDialog.getChild("indentatmf")
-            select_pos(xtab, "0")
-            self.assertEqual(get_state_as_dict(xstyle)["SelectEntryText"], "Heading")
-            self.assertEqual(get_state_as_dict(xnumbering)["SelectEntryText"], "1, 2, 3, ...")
-            self.assertEqual(get_state_as_dict(xcharstyle)["SelectEntryText"], "Bullets")
-            self.assertEqual(get_state_as_dict(xprefix)["Text"], "A")
-            self.assertEqual(get_state_as_dict(xsuffix)["Text"], "B")
-            self.assertEqual(get_state_as_dict(xstartat)["Text"], "2")
-            select_pos(xtab, "1") #second tab Position
-            self.assertEqual(get_state_as_dict(xalignedatmf)["Text"], "0.1 mm")
-            self.assertEqual(get_state_as_dict(xnum2alignlb)["SelectEntryText"], "Centered")
-            self.assertEqual(get_state_as_dict(xnumfollowedbylb)["SelectEntryText"], "Tab stop")
-            self.assertEqual(get_state_as_dict(xatmf)["Text"], "0.1 mm")
-            self.assertEqual(get_state_as_dict(xindentatmf)["Text"], "0.1 mm")
+                xstyle = xDialog.getChild("style")
+                xnumbering = xDialog.getChild("numbering")
+                xcharstyle = xDialog.getChild("charstyle")
+                xprefix = xDialog.getChild("prefix")
+                xsuffix = xDialog.getChild("suffix")
+                xstartat = xDialog.getChild("startat")
+                xtab = xDialog.getChild("tabcontrol")
+                #second tab
+                xalignedatmf = xDialog.getChild("alignedatmf")
+                xnum2alignlb = xDialog.getChild("num2alignlb")
+                xnumfollowedbylb = xDialog.getChild("numfollowedbylb")
+                xatmf = xDialog.getChild("atmf")
+                xindentatmf = xDialog.getChild("indentatmf")
+                select_pos(xtab, "0")
+                self.assertEqual(get_state_as_dict(xstyle)["SelectEntryText"], "Heading")
+                self.assertEqual(get_state_as_dict(xnumbering)["SelectEntryText"], "1, 2, 3, ...")
+                self.assertEqual(get_state_as_dict(xcharstyle)["SelectEntryText"], "Bullets")
+                self.assertEqual(get_state_as_dict(xprefix)["Text"], "A")
+                self.assertEqual(get_state_as_dict(xsuffix)["Text"], "B")
+                self.assertEqual(get_state_as_dict(xstartat)["Text"], "2")
+                select_pos(xtab, "1") #second tab Position
+                self.assertEqual(get_state_as_dict(xalignedatmf)["Text"], "0.1 mm")
+                self.assertEqual(get_state_as_dict(xnum2alignlb)["SelectEntryText"], "Centered")
+                self.assertEqual(get_state_as_dict(xnumfollowedbylb)["SelectEntryText"], "Tab stop")
+                self.assertEqual(get_state_as_dict(xatmf)["Text"], "0.1 mm")
+                self.assertEqual(get_state_as_dict(xindentatmf)["Text"], "0.1 mm")
 
-        self.ui_test.close_doc()
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/chapterNumbering/tdf140528.py b/sw/qa/uitest/chapterNumbering/tdf140528.py
index dc83265899ef..0fc4fc1b51cb 100644
--- a/sw/qa/uitest/chapterNumbering/tdf140528.py
+++ b/sw/qa/uitest/chapterNumbering/tdf140528.py
@@ -13,39 +13,37 @@ from uitest.uihelper.common import select_pos
 class Tdf140528(UITestCase):
 
     def test_tdf140528(self):
-        self.ui_test.create_doc_in_start_center("writer")
-        document = self.ui_test.get_component()
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
 
-        with self.ui_test.execute_dialog_through_command(".uno:ChapterNumberingDialog") as xDialog:
+            with self.ui_test.execute_dialog_through_command(".uno:ChapterNumberingDialog") as xDialog:
 
-            xTab = xDialog.getChild("tabcontrol")
-            select_pos(xTab, "0")
+                xTab = xDialog.getChild("tabcontrol")
+                select_pos(xTab, "0")
 
-            xFormat = xDialog.getChild("format")
+                xFormat = xDialog.getChild("format")
 
-            with self.ui_test.execute_blocking_action(xFormat.executeAction, args=('OPENFROMLIST', mkPropertyValues({"POS": "10"}))) as dialog:
-                xEntry = dialog.getChild("entry")
-                self.assertEqual("Untitled 1", get_state_as_dict(xEntry)['Text'])
+                with self.ui_test.execute_blocking_action(xFormat.executeAction, args=('OPENFROMLIST', mkPropertyValues({"POS": "10"}))) as dialog:
+                    xEntry = dialog.getChild("entry")
+                    self.assertEqual("Untitled 1", get_state_as_dict(xEntry)['Text'])
 
-                xEntry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-                xEntry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
-                xEntry.executeAction("TYPE", mkPropertyValues({"TEXT" : "newFormat"}))
+                    xEntry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+                    xEntry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+                    xEntry.executeAction("TYPE", mkPropertyValues({"TEXT" : "newFormat"}))
 
-            self.assertEqual("saveas", get_state_as_dict(xFormat)['CurrentItem'])
+                self.assertEqual("saveas", get_state_as_dict(xFormat)['CurrentItem'])
 
-            # Go to Position tab
-            select_pos(xTab, "1")
+                # Go to Position tab
+                select_pos(xTab, "1")
 
-            # Go back to Numbering tab
-            select_pos(xTab, "0")
+                # Go back to Numbering tab
+                select_pos(xTab, "0")
 
-            xFormat.executeAction('OPENFROMLIST', mkPropertyValues({"POS": "0"}))
-            self.assertEqual("form1", get_state_as_dict(xFormat)['CurrentItem'])
+                xFormat.executeAction('OPENFROMLIST', mkPropertyValues({"POS": "0"}))
+                self.assertEqual("form1", get_state_as_dict(xFormat)['CurrentItem'])
 
-            # Without the fix in place, this test would have crashed here
-            select_pos(xTab, "1")
+                # Without the fix in place, this test would have crashed here
+                select_pos(xTab, "1")
 
 
-        self.ui_test.close_doc()
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/chart/tdf138556.py b/sw/qa/uitest/chart/tdf138556.py
index 14dbc8675f41..6f06a546bb94 100644
--- a/sw/qa/uitest/chart/tdf138556.py
+++ b/sw/qa/uitest/chart/tdf138556.py
@@ -17,31 +17,30 @@ class tdf138556( UITestCase ):
 
     def test_stock_chart13_insert_series( self ):
         #Start LibreOffice Writer
-        xDocument = self.ui_test.create_doc_in_start_center( "writer" )
-        xMainTop = self.xUITest.getTopFocusWindow()
-
-        #Insert Chart
-        self.xUITest.executeCommand( ".uno:InsertObjectChart" )
-        xChartMainTop = self.xUITest.getTopFocusWindow()
-        xChartMain = xChartMainTop.getChild( "chart_window" )
-        xChart = xChartMain.getChild( "CID/Page=" )
-
-        #Change Chart Type to Stock 1
-        #TODO: test other subtypes
-        with self.ui_test.execute_dialog_through_action( xChart, "COMMAND", mkPropertyValues({ "COMMAND" : "DiagramType" })) as xDialog:
-            xChartType = xDialog.getChild( "charttype" )
-            xStockType = xChartType.getChild( "8" )
-            xStockType.executeAction( "SELECT", tuple())
-
-        #Insert Data Series
-        with self.ui_test.execute_dialog_through_action( xChart, "COMMAND", mkPropertyValues({ "COMMAND" : "DiagramData" }), close_button="close") as xDialog:
-            xToolbar = xDialog.getChild( "toolbar" )
-            xToolbar.executeAction( "CLICK", mkPropertyValues({ "POS" : "1" }))
-
-        #Check Number of Sequences
-        xDocument = self.ui_test.get_component()
-        nSequences = len( xDocument.FirstDiagram.
-            CoordinateSystems[0].ChartTypes[0].DataSeries[0].DataSequences )
-        self.assertEqual( nSequences, 3 )
-
-        self.ui_test.close_doc()
+        with self.ui_test.create_doc_in_start_center_guarded( "writer" ):
+            xMainTop = self.xUITest.getTopFocusWindow()
+
+            #Insert Chart
+            self.xUITest.executeCommand( ".uno:InsertObjectChart" )
+            xChartMainTop = self.xUITest.getTopFocusWindow()
+            xChartMain = xChartMainTop.getChild( "chart_window" )
+            xChart = xChartMain.getChild( "CID/Page=" )
+
+            #Change Chart Type to Stock 1
+            #TODO: test other subtypes
+            with self.ui_test.execute_dialog_through_action( xChart, "COMMAND", mkPropertyValues({ "COMMAND" : "DiagramType" })) as xDialog:
+                xChartType = xDialog.getChild( "charttype" )
+                xStockType = xChartType.getChild( "8" )
+                xStockType.executeAction( "SELECT", tuple())
+
+            #Insert Data Series
+            with self.ui_test.execute_dialog_through_action( xChart, "COMMAND", mkPropertyValues({ "COMMAND" : "DiagramData" }), close_button="close") as xDialog:
+                xToolbar = xDialog.getChild( "toolbar" )
+                xToolbar.executeAction( "CLICK", mkPropertyValues({ "POS" : "1" }))
+
+            #Check Number of Sequences
+            xDocument = self.ui_test.get_component()
+            nSequences = len( xDocument.FirstDiagram.
+                CoordinateSystems[0].ChartTypes[0].DataSeries[0].DataSequences )
+            self.assertEqual( nSequences, 3 )
+
diff --git a/sw/qa/uitest/classification/classification.py b/sw/qa/uitest/classification/classification.py
index e3b4a41e2c99..ab0c88939525 100644
--- a/sw/qa/uitest/classification/classification.py
+++ b/sw/qa/uitest/classification/classification.py
@@ -38,121 +38,115 @@ from libreoffice.uno.propertyvalue import mkPropertyValues
 
 class classification(UITestCase):
     def test_document_classification_dialog(self):
-        writer_doc = self.ui_test.create_doc_in_start_center("writer")
-        document = self.ui_test.get_component()
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        with self.ui_test.execute_dialog_through_command(".uno:ClassificationDialog") as xDialog:
-            classificationEditWindow = xDialog.getChild("classificationEditWindow")
-            recentlyUsedCB = xDialog.getChild("recentlyUsedCB")
-            classificationCB = xDialog.getChild("classificationCB")
-            internationalClassificationCB = xDialog.getChild("internationalClassificationCB")
-            intellectualPropertyPartEntry = xDialog.getChild("intellectualPropertyPartEntry")
-            intellectualPropertyPartAddButton = xDialog.getChild("intellectualPropertyPartAddButton")
-
-            select_by_text(classificationCB, "Confidential")
-            #verify International is set too
-            self.assertEqual(get_state_as_dict(internationalClassificationCB)["SelectEntryText"], "Confidential")
-            #verify textBox Content
-            # self.assertEqual(get_state_as_dict(classificationEditWindow)["Text"], "Conf")
-
-        header = document.StyleFamilies.PageStyles.Standard.HeaderText.createEnumeration().nextElement()
-        self.assertEqual(header.String, "Confidential")
-
-        controller = self.ui_test.get_component().getCurrentController()
-        self.assertTrue(controller.hasInfobar("classification"))
-
-        #verify watermark
-        #Bug 122586 - Classification: by using the dialog, Watermark text from policy is not placed in the document
-        with self.ui_test.execute_dialog_through_command(".uno:Watermark", close_button="cancel") as xDialog:
-            xTextInput = xDialog.getChild("TextInput")
-            xAngle = xDialog.getChild("Angle")
-            xTransparency = xDialog.getChild("Transparency")
-            self.assertEqual(get_state_as_dict(xTextInput)["Text"], "Confidential")
-            self.assertEqual(get_state_as_dict(xAngle)["Text"], "45°")
-            self.assertEqual((get_state_as_dict(xTransparency)["Text"])[0:2], "50")
-
-        #TODO
-        #open dialog and add intellectualProperty text, save
-        #verify
-        #reopen and verify classification and Content
-
-        #do the same for Paragraph classification
-        with self.ui_test.execute_dialog_through_command(".uno:ParagraphClassificationDialog") as xDialog:
-            classificationEditWindow = xDialog.getChild("classificationEditWindow")
-            recentlyUsedCB = xDialog.getChild("recentlyUsedCB")
-            classificationCB = xDialog.getChild("classificationCB")
-            internationalClassificationCB = xDialog.getChild("internationalClassificationCB")
-            intellectualPropertyPartEntry = xDialog.getChild("intellectualPropertyPartEntry")
-            intellectualPropertyPartAddButton = xDialog.getChild("intellectualPropertyPartAddButton")
-
-            select_by_text(classificationCB, "Confidential")
-            #verify International is set too
-            self.assertEqual(get_state_as_dict(internationalClassificationCB)["SelectEntryText"], "Confidential")
-            #verify textBox Content  TODO textbox not supported
-            #self.assertEqual(get_state_as_dict(classificationEditWindow)["Text"], "Conf")
-            # print(get_state_as_dict(classificationEditWindow))
-
-
-        self.assertEqual(document.Text.String[0:6], "(Conf)")
-        self.assertEqual(header.String, "Confidential")
-        self.assertTrue(controller.hasInfobar("classification"))
+        with self.ui_test.create_doc_in_start_center_guarded("writer") as document:
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            with self.ui_test.execute_dialog_through_command(".uno:ClassificationDialog") as xDialog:
+                classificationEditWindow = xDialog.getChild("classificationEditWindow")
+                recentlyUsedCB = xDialog.getChild("recentlyUsedCB")
+                classificationCB = xDialog.getChild("classificationCB")
+                internationalClassificationCB = xDialog.getChild("internationalClassificationCB")
+                intellectualPropertyPartEntry = xDialog.getChild("intellectualPropertyPartEntry")
+                intellectualPropertyPartAddButton = xDialog.getChild("intellectualPropertyPartAddButton")
+
+                select_by_text(classificationCB, "Confidential")
+                #verify International is set too
+                self.assertEqual(get_state_as_dict(internationalClassificationCB)["SelectEntryText"], "Confidential")
+                #verify textBox Content
+                # self.assertEqual(get_state_as_dict(classificationEditWindow)["Text"], "Conf")
+
+            header = document.StyleFamilies.PageStyles.Standard.HeaderText.createEnumeration().nextElement()
+            self.assertEqual(header.String, "Confidential")
+
+            controller = document.getCurrentController()
+            self.assertTrue(controller.hasInfobar("classification"))
+
+            #verify watermark
+            #Bug 122586 - Classification: by using the dialog, Watermark text from policy is not placed in the document
+            with self.ui_test.execute_dialog_through_command(".uno:Watermark", close_button="cancel") as xDialog:
+                xTextInput = xDialog.getChild("TextInput")
+                xAngle = xDialog.getChild("Angle")
+                xTransparency = xDialog.getChild("Transparency")
+                self.assertEqual(get_state_as_dict(xTextInput)["Text"], "Confidential")
+                self.assertEqual(get_state_as_dict(xAngle)["Text"], "45°")
+                self.assertEqual((get_state_as_dict(xTransparency)["Text"])[0:2], "50")
+
+            #TODO
+            #open dialog and add intellectualProperty text, save
+            #verify
+            #reopen and verify classification and Content
+
+            #do the same for Paragraph classification
+            with self.ui_test.execute_dialog_through_command(".uno:ParagraphClassificationDialog") as xDialog:
+                classificationEditWindow = xDialog.getChild("classificationEditWindow")
+                recentlyUsedCB = xDialog.getChild("recentlyUsedCB")
+                classificationCB = xDialog.getChild("classificationCB")
+                internationalClassificationCB = xDialog.getChild("internationalClassificationCB")
+                intellectualPropertyPartEntry = xDialog.getChild("intellectualPropertyPartEntry")
+                intellectualPropertyPartAddButton = xDialog.getChild("intellectualPropertyPartAddButton")
+
+                select_by_text(classificationCB, "Confidential")
+                #verify International is set too
+                self.assertEqual(get_state_as_dict(internationalClassificationCB)["SelectEntryText"], "Confidential")
+                #verify textBox Content  TODO textbox not supported
+                #self.assertEqual(get_state_as_dict(classificationEditWindow)["Text"], "Conf")
+                # print(get_state_as_dict(classificationEditWindow))
+
+
+            self.assertEqual(document.Text.String[0:6], "(Conf)")
+            self.assertEqual(header.String, "Confidential")
+            self.assertTrue(controller.hasInfobar("classification"))
 
-        self.ui_test.close_doc()
 
     def test_paragraph_classification_dialog(self):
-        writer_doc = self.ui_test.create_doc_in_start_center("writer")
-        document = self.ui_test.get_component()
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        #+ new file and do it only for Paragraph classification (no watermark!)
-        with self.ui_test.execute_dialog_through_command(".uno:ParagraphClassificationDialog") as xDialog:
-            classificationEditWindow = xDialog.getChild("classificationEditWindow")
-            recentlyUsedCB = xDialog.getChild("recentlyUsedCB")
-            classificationCB = xDialog.getChild("classificationCB")
-            internationalClassificationCB = xDialog.getChild("internationalClassificationCB")
-            intellectualPropertyPartEntry = xDialog.getChild("intellectualPropertyPartEntry")
-            intellectualPropertyPartAddButton = xDialog.getChild("intellectualPropertyPartAddButton")
-
-            select_by_text(classificationCB, "Confidential")
-            #verify International is set too
-            self.assertEqual(get_state_as_dict(internationalClassificationCB)["SelectEntryText"], "Confidential")
-            #verify textBox Content  TODO  - texbox not supported yet
-            # self.assertEqual(get_state_as_dict(classificationEditWindow)["Text"], "Conf")
-            # print(get_state_as_dict(classificationEditWindow))
-
+        with self.ui_test.create_doc_in_start_center_guarded("writer") as document:
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            #+ new file and do it only for Paragraph classification (no watermark!)
+            with self.ui_test.execute_dialog_through_command(".uno:ParagraphClassificationDialog") as xDialog:
+                classificationEditWindow = xDialog.getChild("classificationEditWindow")
+                recentlyUsedCB = xDialog.getChild("recentlyUsedCB")
+                classificationCB = xDialog.getChild("classificationCB")
+                internationalClassificationCB = xDialog.getChild("internationalClassificationCB")
+                intellectualPropertyPartEntry = xDialog.getChild("intellectualPropertyPartEntry")
+                intellectualPropertyPartAddButton = xDialog.getChild("intellectualPropertyPartAddButton")
+
+                select_by_text(classificationCB, "Confidential")
+                #verify International is set too
+                self.assertEqual(get_state_as_dict(internationalClassificationCB)["SelectEntryText"], "Confidential")
+                #verify textBox Content  TODO  - texbox not supported yet
+                # self.assertEqual(get_state_as_dict(classificationEditWindow)["Text"], "Conf")
+                # print(get_state_as_dict(classificationEditWindow))
+
+
+            controller = document.getCurrentController()
+            self.assertEqual(document.Text.String[0:6], "(Conf)")
+            self.assertFalse(controller.hasInfobar("classification"))
+            self.assertFalse(document.StyleFamilies.PageStyles.Standard.HeaderIsOn)
 
-        controller = self.ui_test.get_component().getCurrentController()
-        self.assertEqual(document.Text.String[0:6], "(Conf)")
-        self.assertFalse(controller.hasInfobar("classification"))
-        self.assertFalse(document.StyleFamilies.PageStyles.Standard.HeaderIsOn)
-
-        self.ui_test.close_doc()
 
     def test_paragraph_classification_dialog_text(self):
-        writer_doc = self.ui_test.create_doc_in_start_center("writer")
-        document = self.ui_test.get_component()
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        #+ new file and do it only for Paragraph classification (no watermark!)
-        with self.ui_test.execute_dialog_through_command(".uno:ParagraphClassificationDialog") as xDialog:
-            classificationEditWindow = xDialog.getChild("classificationEditWindow")
-            recentlyUsedCB = xDialog.getChild("recentlyUsedCB")
-            classificationCB = xDialog.getChild("classificationCB")
-            internationalClassificationCB = xDialog.getChild("internationalClassificationCB")
-            intellectualPropertyPartEntry = xDialog.getChild("intellectualPropertyPartEntry")
-            intellectualPropertyPartAddButton = xDialog.getChild("intellectualPropertyPartAddButton")
-            #type text AA
-            intellectualPropertyPartEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"AA"}))
-            intellectualPropertyPartAddButton.executeAction("CLICK", tuple())
-            select_by_text(classificationCB, "Internal Only")
-            #verify International is set too
-            self.assertEqual(get_state_as_dict(internationalClassificationCB)["SelectEntryText"], "Internal Only")
-            #verify textBox Content  TODO  - texbox not supported yet
-            # self.assertEqual(get_state_as_dict(classificationEditWindow)["Text"], "Conf")
-
-
-        controller = self.ui_test.get_component().getCurrentController()
-        self.assertEqual(document.Text.String[0:6], "(AAIO)")
-        self.assertFalse(controller.hasInfobar("classification"))
-        self.assertFalse(document.StyleFamilies.PageStyles.Standard.HeaderIsOn)
-
-        self.ui_test.close_doc()
+        with self.ui_test.create_doc_in_start_center_guarded("writer") as document:
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            #+ new file and do it only for Paragraph classification (no watermark!)
+            with self.ui_test.execute_dialog_through_command(".uno:ParagraphClassificationDialog") as xDialog:
+                classificationEditWindow = xDialog.getChild("classificationEditWindow")
+                recentlyUsedCB = xDialog.getChild("recentlyUsedCB")
+                classificationCB = xDialog.getChild("classificationCB")
+                internationalClassificationCB = xDialog.getChild("internationalClassificationCB")
+                intellectualPropertyPartEntry = xDialog.getChild("intellectualPropertyPartEntry")
+                intellectualPropertyPartAddButton = xDialog.getChild("intellectualPropertyPartAddButton")
+                #type text AA
+                intellectualPropertyPartEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"AA"}))
+                intellectualPropertyPartAddButton.executeAction("CLICK", tuple())
+                select_by_text(classificationCB, "Internal Only")
+                #verify International is set too
+                self.assertEqual(get_state_as_dict(internationalClassificationCB)["SelectEntryText"], "Internal Only")
+                #verify textBox Content  TODO  - texbox not supported yet
+                # self.assertEqual(get_state_as_dict(classificationEditWindow)["Text"], "Conf")
+
+
+            controller = document.getCurrentController()
+            self.assertEqual(document.Text.String[0:6], "(AAIO)")
+            self.assertFalse(controller.hasInfobar("classification"))
+            self.assertFalse(document.StyleFamilies.PageStyles.Standard.HeaderIsOn)
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/findBar/findbar.py b/sw/qa/uitest/findBar/findbar.py
index 75bfbb33abd9..288a9df1013b 100644
--- a/sw/qa/uitest/findBar/findbar.py
+++ b/sw/qa/uitest/findBar/findbar.py
@@ -16,54 +16,53 @@ class FindBar(UITestCase):
 
     def test_find_bar(self):
 
-        self.ui_test.create_doc_in_start_center("writer")
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            xWriterEdit = xWriterDoc.getChild("writer_edit")
 
-        # Type some lines to search for words on them
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "LibreOffice"}))
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "LibreOffice Writer"}))
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "LibreOffice Calc"}))
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "The Document Foundation"}))
+            # Type some lines to search for words on them
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "LibreOffice"}))
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "LibreOffice Writer"}))
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "LibreOffice Calc"}))
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "The Document Foundation"}))
 
-        # open the Find Bar
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+f"}))
+            # open the Find Bar
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+f"}))
 
-        # Type the Word that we want to search for it
-        xfind = xWriterDoc.getChild("find")
-        xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "Libre"}))
+            # Type the Word that we want to search for it
+            xfind = xWriterDoc.getChild("find")
+            xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "Libre"}))
 
-        # Select the Find Bar
-        xfind_bar = xWriterDoc.getChild("FindBar")
-        self.assertEqual(get_state_as_dict(xfind_bar)["ItemCount"], "14")
+            # Select the Find Bar
+            xfind_bar = xWriterDoc.getChild("FindBar")
+            self.assertEqual(get_state_as_dict(xfind_bar)["ItemCount"], "14")
 
-        # Press on FindAll in the Find Bar
-        xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "4"}))
-        self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemID"], "5") # 5 is FindAll id for Pos 4
-        self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemText"], "Find All")
-        self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemCommand"], ".uno:FindAll")
-        self.assertEqual(get_state_as_dict(xWriterEdit)["SelectedText"], "LibreLibreLibre")
+            # Press on FindAll in the Find Bar
+            xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "4"}))
+            self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemID"], "5") # 5 is FindAll id for Pos 4
+            self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemText"], "Find All")
+            self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemCommand"], ".uno:FindAll")
+            self.assertEqual(get_state_as_dict(xWriterEdit)["SelectedText"], "LibreLibreLibre")
 
-        # Press on Find Next in the Find Bar
-        xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"}))  # 3 is Find Next pos
-        self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemID"], "4")
-        self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemText"], "Find Next")
-        self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemCommand"], ".uno:DownSearch")
-        self.assertEqual(get_state_as_dict(xWriterEdit)["SelectedText"], "Libre")
+            # Press on Find Next in the Find Bar
+            xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"}))  # 3 is Find Next pos
+            self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemID"], "4")
+            self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemText"], "Find Next")
+            self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemCommand"], ".uno:DownSearch")
+            self.assertEqual(get_state_as_dict(xWriterEdit)["SelectedText"], "Libre")
 
-        # Press on Find Previous in the Find Bar
-        xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "2"}))  # 2 is Find Previous pos
-        self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemID"], "3")
-        self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemText"], "Find Previous")
-        self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemCommand"], ".uno:UpSearch")
-        self.assertEqual(get_state_as_dict(xWriterEdit)["SelectedText"], "Libre")
+            # Press on Find Previous in the Find Bar
+            xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "2"}))  # 2 is Find Previous pos
+            self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemID"], "3")
+            self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemText"], "Find Previous")
+            self.assertEqual(get_state_as_dict(xfind_bar)["CurrSelectedItemCommand"], ".uno:UpSearch")
+            self.assertEqual(get_state_as_dict(xWriterEdit)["SelectedText"], "Libre")
 
-        # Close the Find Bar
-        xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "0"}))  # 0 is pos for close
+            # Close the Find Bar
+            xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "0"}))  # 0 is pos for close
 
-        self.ui_test.close_doc()
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/findBar/tdf136941.py b/sw/qa/uitest/findBar/tdf136941.py
index c77a7e2a2277..99b8b33acba7 100644
--- a/sw/qa/uitest/findBar/tdf136941.py
+++ b/sw/qa/uitest/findBar/tdf136941.py
@@ -12,55 +12,54 @@ class tdf136941(UITestCase):
 
     def test_tdf136941(self):
 
-        self.ui_test.create_doc_in_start_center("writer")
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            xWriterEdit = xWriterDoc.getChild("writer_edit")
 
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello World"}))
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello World"}))
 
-        self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar")
+            self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar")
 
-        xfind = xWriterDoc.getChild("find")
-        xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"}))
+            xfind = xWriterDoc.getChild("find")
+            xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"}))
 
-        self.assertEqual("Hello", get_state_as_dict(xfind)['Text'])
+            self.assertEqual("Hello", get_state_as_dict(xfind)['Text'])
 
-        xfind_bar = xWriterDoc.getChild("FindBar")
+            xfind_bar = xWriterDoc.getChild("FindBar")
 
-        # Search Next
-        xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"}))
+            # Search Next
+            xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"}))
 
-        # Close button
-        xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "0"}))
+            # Close button
+            xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "0"}))
 
-        # Check the toolbar is closed
-        self.assertTrue("find" not in xWriterDoc.getChildren())
-        self.assertEqual("Hello", get_state_as_dict(xWriterEdit)['SelectedText'])
+            # Check the toolbar is closed
+            self.assertTrue("find" not in xWriterDoc.getChildren())
+            self.assertEqual("Hello", get_state_as_dict(xWriterEdit)['SelectedText'])
 
-        self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar")
+            self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar")
 
-        xfind = xWriterDoc.getChild("find")
-        self.ui_test.wait_until_property_is_updated(xfind, 'SelectedText', "Hello")
-        self.assertEqual("Hello", get_state_as_dict(xfind)['SelectedText'])
+            xfind = xWriterDoc.getChild("find")
+            self.ui_test.wait_until_property_is_updated(xfind, 'SelectedText', "Hello")
+            self.assertEqual("Hello", get_state_as_dict(xfind)['SelectedText'])
 
-        xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "World"}))
+            xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "World"}))
 
-        # Without the fix in place, this test would have failed with
-        # AssertionError: 'World' != 'WorldHello'
-        self.assertEqual("World", get_state_as_dict(xfind)['Text'])
+            # Without the fix in place, this test would have failed with
+            # AssertionError: 'World' != 'WorldHello'
+            self.assertEqual("World", get_state_as_dict(xfind)['Text'])
 
-        xfind_bar = xWriterDoc.getChild("FindBar")
+            xfind_bar = xWriterDoc.getChild("FindBar")
 
-        # Search Next
-        xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"}))
+            # Search Next
+            xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"}))
 
-        # Close button
-        xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "0"}))
+            # Close button
+            xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "0"}))
 
-        # Check the toolbar is closed
-        self.assertTrue("find" not in xWriterDoc.getChildren())
-        self.assertEqual("World", get_state_as_dict(xWriterEdit)['SelectedText'])
+            # Check the toolbar is closed
+            self.assertTrue("find" not in xWriterDoc.getChildren())
+            self.assertEqual("World", get_state_as_dict(xWriterEdit)['SelectedText'])
 
-        self.ui_test.close_doc()
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/findBar/tdf138232.py b/sw/qa/uitest/findBar/tdf138232.py
index 62a79824ea4d..f6ec1161c56d 100644
--- a/sw/qa/uitest/findBar/tdf138232.py
+++ b/sw/qa/uitest/findBar/tdf138232.py
@@ -12,40 +12,39 @@ class tdf138232(UITestCase):
 
     def test_tdf138232(self):
 
-        self.ui_test.create_doc_in_start_center("writer")
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            xWriterEdit = xWriterDoc.getChild("writer_edit")
 
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"}))
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"}))
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"}))
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"}))
 
-        self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar")
+            self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar")
 
-        xfind = xWriterDoc.getChild("find")
-        self.ui_test.wait_until_property_is_updated(xfind, 'HasFocus', "true")
-        self.assertEqual("true", get_state_as_dict(xfind)['HasFocus'])
+            xfind = xWriterDoc.getChild("find")
+            self.ui_test.wait_until_property_is_updated(xfind, 'HasFocus', "true")
+            self.assertEqual("true", get_state_as_dict(xfind)['HasFocus'])
 
-        xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"}))
-        self.assertEqual("Hello", get_state_as_dict(xfind)['Text'])
+            xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"}))
+            self.assertEqual("Hello", get_state_as_dict(xfind)['Text'])
 
-        xfind_bar = xWriterDoc.getChild("FindBar")
+            xfind_bar = xWriterDoc.getChild("FindBar")
 
-        # Click on Find All
-        xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "4"}))
+            # Click on Find All
+            xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "4"}))
 
-        self.assertEqual("HelloHello", get_state_as_dict(xWriterEdit)['SelectedText'])
+            self.assertEqual("HelloHello", get_state_as_dict(xWriterEdit)['SelectedText'])
 
-        xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "World"}))
+            xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "World"}))
 
-        # Without the fix in place, this test would have failed with
-        # AssertionError: 'HelloWorld' != 'World'
-        self.assertEqual("HelloWorld", get_state_as_dict(xfind)['Text'])
+            # Without the fix in place, this test would have failed with
+            # AssertionError: 'HelloWorld' != 'World'
+            self.assertEqual("HelloWorld", get_state_as_dict(xfind)['Text'])
 
-        xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "4"}))
+            xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "4"}))
 
-        self.assertEqual("", get_state_as_dict(xWriterEdit)['SelectedText'])
+            self.assertEqual("", get_state_as_dict(xWriterEdit)['SelectedText'])
 
-        self.ui_test.close_doc()
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/findBar/tdf88608.py b/sw/qa/uitest/findBar/tdf88608.py
index b3576ec7587e..050f234b075e 100644
--- a/sw/qa/uitest/findBar/tdf88608.py
+++ b/sw/qa/uitest/findBar/tdf88608.py
@@ -12,44 +12,43 @@ class tdf88608(UITestCase):
 
     def test_tdf88608(self):
 
-        self.ui_test.create_doc_in_start_center("writer")
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            xWriterEdit = xWriterDoc.getChild("writer_edit")
 
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello World"}))
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello World"}))
 
-        self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar")
+            self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar")
 
-        # Search a word that doesn't exist
-        xfind = xWriterDoc.getChild("find")
-        xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "X"}))
-        self.assertEqual("X", get_state_as_dict(xfind)['Text'])
+            # Search a word that doesn't exist
+            xfind = xWriterDoc.getChild("find")
+            xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "X"}))
+            self.assertEqual("X", get_state_as_dict(xfind)['Text'])
 
-        xfind_bar = xWriterDoc.getChild("FindBar")
-        self.assertEqual('', get_state_as_dict(xfind_bar.getChild('label'))['Text'])
+            xfind_bar = xWriterDoc.getChild("FindBar")
+            self.assertEqual('', get_state_as_dict(xfind_bar.getChild('label'))['Text'])
 
-        # Search Next
-        xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"}))
+            # Search Next
+            xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"}))
 
-        self.assertEqual('Search key not found', get_state_as_dict(xfind_bar.getChild('label'))['Text'])
+            self.assertEqual('Search key not found', get_state_as_dict(xfind_bar.getChild('label'))['Text'])
 
-        self.assertEqual("", get_state_as_dict(xWriterEdit)['SelectedText'])
+            self.assertEqual("", get_state_as_dict(xWriterEdit)['SelectedText'])
 
-        xfind.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
-        xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "World"}))
-        self.assertEqual("World", get_state_as_dict(xfind)['Text'])
+            xfind.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
+            xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "World"}))
+            self.assertEqual("World", get_state_as_dict(xfind)['Text'])
 
-        # Without the fix in place, this test would have failed with
-        # AssertionError: '' != 'Search key not found'
-        self.assertEqual('', get_state_as_dict(xfind_bar.getChild('label'))['Text'])
+            # Without the fix in place, this test would have failed with
+            # AssertionError: '' != 'Search key not found'
+            self.assertEqual('', get_state_as_dict(xfind_bar.getChild('label'))['Text'])
 
-        # Search Next
-        xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"}))
+            # Search Next
+            xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"}))
 
-        self.assertEqual('Reached the end of the document', get_state_as_dict(xfind_bar.getChild('label'))['Text'])
+            self.assertEqual('Reached the end of the document', get_state_as_dict(xfind_bar.getChild('label'))['Text'])
 
-        self.assertEqual("World", get_state_as_dict(xWriterEdit)['SelectedText'])
+            self.assertEqual("World", get_state_as_dict(xWriterEdit)['SelectedText'])
 
-        self.ui_test.close_doc()
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/findReplace/findReplace.py b/sw/qa/uitest/findReplace/findReplace.py
index 68f9f882b3e9..d9128ec23e6b 100644
--- a/sw/qa/uitest/findReplace/findReplace.py
+++ b/sw/qa/uitest/findReplace/findReplace.py
@@ -94,30 +94,28 @@ class findReplace(UITestCase):
 
         #Bug 39022 - find-replace->$1, not pattern
     def test_tdf39022_replace_regexp(self):
-        writer_doc = self.ui_test.create_doc_in_start_center("writer")
-        document = self.ui_test.get_component()
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
-        type_text(xWriterEdit, "test number1 testnot")
-
-        self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        searchterm = xDialog.getChild("searchterm")
-        searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"T(est|other)\\>"}))   #find
-        replaceterm = xDialog.getChild("replaceterm")
-        replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"replaced$1"})) #replace
-        regexp = xDialog.getChild("regexp")
-        regexp.executeAction("CLICK", tuple())   #regular expressions
-        replaceall = xDialog.getChild("replaceall")
-        replaceall.executeAction("CLICK", tuple())
-        #verify
-        self.assertEqual(document.Text.String[0:27], "replacedest number1 testnot")
-        regexp.executeAction("CLICK", tuple())
-
-        xcloseBtn = xDialog.getChild("close")
-        self.ui_test.close_dialog_through_button(xcloseBtn)
-
-        self.ui_test.close_doc()
+        with self.ui_test.create_doc_in_start_center_guarded("writer") as document:
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            xWriterEdit = xWriterDoc.getChild("writer_edit")
+            type_text(xWriterEdit, "test number1 testnot")
+
+            self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+            xDialog = self.xUITest.getTopFocusWindow()
+            searchterm = xDialog.getChild("searchterm")
+            searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"T(est|other)\\>"}))   #find
+            replaceterm = xDialog.getChild("replaceterm")
+            replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"replaced$1"})) #replace
+            regexp = xDialog.getChild("regexp")
+            regexp.executeAction("CLICK", tuple())   #regular expressions
+            replaceall = xDialog.getChild("replaceall")
+            replaceall.executeAction("CLICK", tuple())
+            #verify
+            self.assertEqual(document.Text.String[0:27], "replacedest number1 testnot")
+            regexp.executeAction("CLICK", tuple())
+
+            xcloseBtn = xDialog.getChild("close")
+            self.ui_test.close_dialog_through_button(xcloseBtn)
+
 
         #tdf116242  ţ ț
     def test_tdf116242_replace_t_with_cedilla(self):
@@ -167,34 +165,32 @@ class findReplace(UITestCase):
             self.ui_test.close_dialog_through_button(xcloseBtn)
 
     def test_tdf136577(self):
-        self.ui_test.create_doc_in_start_center("writer")
+        with self.ui_test.create_doc_in_start_center_guarded("writer") as document:
 
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            xWriterEdit = xWriterDoc.getChild("writer_edit")
 
-        document = self.ui_test.get_component()
 
-        type_text(xWriterEdit, "x")
+            type_text(xWriterEdit, "x")
 
-        self.assertEqual(document.Text.String, "x")
+            self.assertEqual(document.Text.String, "x")
 
-        self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
+            self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+            xDialog = self.xUITest.getTopFocusWindow()
 
-        searchterm = xDialog.getChild("searchterm")
-        searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"x"}))
+            searchterm = xDialog.getChild("searchterm")
+            searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"x"}))
 
 
-        replaceall = xDialog.getChild("replaceall")
-        replaceall.executeAction("CLICK", tuple())
+            replaceall = xDialog.getChild("replaceall")
+            replaceall.executeAction("CLICK", tuple())
 
-        self.assertEqual(document.Text.String, "")
+            self.assertEqual(document.Text.String, "")
 
-        self.xUITest.executeCommand(".uno:Undo")
+            self.xUITest.executeCommand(".uno:Undo")
 
-        # Without the fix in place, this test would have failed with AssertionError: '' != 'x'
-        self.assertEqual(document.Text.String, "x")
+            # Without the fix in place, this test would have failed with AssertionError: '' != 'x'
+            self.assertEqual(document.Text.String, "x")
 
-        self.ui_test.close_doc()
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/findReplace/tdf106099.py b/sw/qa/uitest/findReplace/tdf106099.py
index d0c1ad76f251..483bf2c3aff6 100644
--- a/sw/qa/uitest/findReplace/tdf106099.py
+++ b/sw/qa/uitest/findReplace/tdf106099.py
@@ -13,30 +13,28 @@ from uitest.uihelper.common import get_state_as_dict
 
 class tdf106099(UITestCase):
     def test_tdf106099_find_format_underline(self):
-        writer_doc = self.ui_test.create_doc_in_start_center("writer")
-        document = self.ui_test.get_component()
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        #Find and replace
-        self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        #2. Choose Format
-        format = xDialog.getChild("format")
-        with self.ui_test.execute_blocking_action(format.executeAction, args=('CLICK', ())) as dialog:
-            #Font effects - Underline Single. OK.
-            xTabs = dialog.getChild("tabcontrol")
-            select_pos(xTabs, "1")          #tab font effects
-            underlinelb = dialog.getChild("underlinelb")
-            select_by_text(underlinelb, "Single")
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            #Find and replace
+            self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+            xDialog = self.xUITest.getTopFocusWindow()
+            #2. Choose Format
+            format = xDialog.getChild("format")
+            with self.ui_test.execute_blocking_action(format.executeAction, args=('CLICK', ())) as dialog:
+                #Font effects - Underline Single. OK.
+                xTabs = dialog.getChild("tabcontrol")
+                select_pos(xTabs, "1")          #tab font effects
+                underlinelb = dialog.getChild("underlinelb")
+                select_by_text(underlinelb, "Single")
 
-        #verify label searchdesc
-        searchdesc = xDialog.getChild("searchdesc")
-        print(get_state_as_dict(searchdesc))
-        self.assertEqual(get_state_as_dict(searchdesc)["Text"], "Single underline")
-        noformat = xDialog.getChild("noformat")
-        noformat.executeAction("CLICK", tuple())   #click No format button
-        self.assertEqual(get_state_as_dict(searchdesc)["Text"], "")
-        xcloseBtn = xDialog.getChild("close")
-        self.ui_test.close_dialog_through_button(xcloseBtn)
+            #verify label searchdesc
+            searchdesc = xDialog.getChild("searchdesc")
+            print(get_state_as_dict(searchdesc))
+            self.assertEqual(get_state_as_dict(searchdesc)["Text"], "Single underline")
+            noformat = xDialog.getChild("noformat")
+            noformat.executeAction("CLICK", tuple())   #click No format button
+            self.assertEqual(get_state_as_dict(searchdesc)["Text"], "")
+            xcloseBtn = xDialog.getChild("close")
+            self.ui_test.close_dialog_through_button(xcloseBtn)
 
-        self.ui_test.close_doc()
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/findReplace/tdf119462.py b/sw/qa/uitest/findReplace/tdf119462.py
index 4402d1acaedd..3c3601193311 100644
--- a/sw/qa/uitest/findReplace/tdf119462.py
+++ b/sw/qa/uitest/findReplace/tdf119462.py
@@ -13,29 +13,27 @@ from uitest.uihelper.common import get_state_as_dict
 
 class tdf119462(UITestCase):
     def test_tdf119462_find_format(self):
-        writer_doc = self.ui_test.create_doc_in_start_center("writer")
-        document = self.ui_test.get_component()
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        #1. Choose Edit > Find and Replace
-        self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
-        #2. Choose Format
-        format = xDialog.getChild("format")
-        with self.ui_test.execute_blocking_action(format.executeAction, args=('CLICK', ())) as dialog:
-            #3. Choose Bold
-            xTabs = dialog.getChild("tabcontrol")
-            select_pos(xTabs, "0")
-            xweststylelbcjk = dialog.getChild("weststylelb-cjk")
-            xweststylelbcjk.executeAction("TYPE", mkPropertyValues({"TEXT":"Bold"}))
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            #1. Choose Edit > Find and Replace
+            self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+            xDialog = self.xUITest.getTopFocusWindow()
+            #2. Choose Format
+            format = xDialog.getChild("format")
+            with self.ui_test.execute_blocking_action(format.executeAction, args=('CLICK', ())) as dialog:
+                #3. Choose Bold
+                xTabs = dialog.getChild("tabcontrol")
+                select_pos(xTabs, "0")
+                xweststylelbcjk = dialog.getChild("weststylelb-cjk")
+                xweststylelbcjk.executeAction("TYPE", mkPropertyValues({"TEXT":"Bold"}))
 
-        #verify label searchdesc
-        searchdesc = xDialog.getChild("searchdesc")
-        self.assertEqual(get_state_as_dict(searchdesc)["Text"], "bold")
-        noformat = xDialog.getChild("noformat")
-        noformat.executeAction("CLICK", tuple())   #click No format button
-        self.assertEqual(get_state_as_dict(searchdesc)["Text"], "")
-        xcloseBtn = xDialog.getChild("close")
-        self.ui_test.close_dialog_through_button(xcloseBtn)
+            #verify label searchdesc
+            searchdesc = xDialog.getChild("searchdesc")
+            self.assertEqual(get_state_as_dict(searchdesc)["Text"], "bold")
+            noformat = xDialog.getChild("noformat")
+            noformat.executeAction("CLICK", tuple())   #click No format button
+            self.assertEqual(get_state_as_dict(searchdesc)["Text"], "")
+            xcloseBtn = xDialog.getChild("close")
+            self.ui_test.close_dialog_through_button(xcloseBtn)
 
-        self.ui_test.close_doc()
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/librelogo/run.py b/sw/qa/uitest/librelogo/run.py
index 26b8f5c7df44..7d7ca4611f3b 100644
--- a/sw/qa/uitest/librelogo/run.py
+++ b/sw/qa/uitest/librelogo/run.py
@@ -28,43 +28,42 @@ class LibreLogoTest(UITestCase):
         self.xUITest.executeCommand(self.LIBRELOGO_PATH %command)
 
    def test_librelogo(self):
-        self.ui_test.create_doc_in_start_center("writer")
-        document = self.ui_test.get_component()
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
-        # to check the state of LibreLogo program execution
-        xIsAlive = self.getScript("__is_alive__")
+        with self.ui_test.create_doc_in_start_center_guarded("writer") as document:
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            xWriterEdit = xWriterDoc.getChild("writer_edit")
+            # to check the state of LibreLogo program execution
+            xIsAlive = self.getScript("__is_alive__")
 
-        # run a program with basic drawing commands FORWARD and RIGHT
-        # using their abbreviated names FD and RT
-        type_text(xWriterEdit, "fd 100 rt 45 fd 100")
-        self.logo("run")
-        # wait for LibreLogo program termination
-        while xIsAlive.invoke((), (), ())[0]:
-            pass
-        # check shape count for
-        # a) program running:
-        # - turtle shape: result of program start
-        # - line shape: result of turtle drawing
-        # b) continuous line drawing (the regression
-        # related to the fix of tdf#106792 resulted shorter line
-        # segments than the turtle path and non-continuous line
-        # drawing, ie. in this example, three line shapes
-        # instead of a single one. See its fix in
-        # commit 502e8785085f9e8b54ee383080442c2dcaf95b15)
-        self.assertEqual(document.DrawPage.getCount(), 2)
+            # run a program with basic drawing commands FORWARD and RIGHT
+            # using their abbreviated names FD and RT
+            type_text(xWriterEdit, "fd 100 rt 45 fd 100")
+            self.logo("run")
+            # wait for LibreLogo program termination
+            while xIsAlive.invoke((), (), ())[0]:
+                pass
+            # check shape count for
+            # a) program running:
+            # - turtle shape: result of program start
+            # - line shape: result of turtle drawing
+            # b) continuous line drawing (the regression
+            # related to the fix of tdf#106792 resulted shorter line
+            # segments than the turtle path and non-continuous line
+            # drawing, ie. in this example, three line shapes
+            # instead of a single one. See its fix in
+            # commit 502e8785085f9e8b54ee383080442c2dcaf95b15)
+            self.assertEqual(document.DrawPage.getCount(), 2)
 
-        # check formatting by "magic wand"
-        self.logo("__translate__")
-        # a) check expansion of abbreviated commands : fd -> FORWARD, rt -> RIGHT,
-        # b) check line breaking (fix for tdf#100941: new line instead of the text "\" and "n")
-        self.assertEqual(document.Text.String.replace('\r\n', '\n'), "\nFORWARD 100 RIGHT 45 FORWARD 100")
-        # c) check usage of real paragraphs instead of line break (tdf#120422)
-        # first paragraph is empty (for working page break)
-        self.assertEqual(document.Text.createEnumeration().nextElement().String, "")
+            # check formatting by "magic wand"
+            self.logo("__translate__")
+            # a) check expansion of abbreviated commands : fd -> FORWARD, rt -> RIGHT,
+            # b) check line breaking (fix for tdf#100941: new line instead of the text "\" and "n")
+            self.assertEqual(document.Text.String.replace('\r\n', '\n'), "\nFORWARD 100 RIGHT 45 FORWARD 100")
+            # c) check usage of real paragraphs instead of line break (tdf#120422)
+            # first paragraph is empty (for working page break)
+            self.assertEqual(document.Text.createEnumeration().nextElement().String, "")
 
-        # function definitions and calls can be in arbitrary order
-        document.Text.String = """
+            # function definitions and calls can be in arbitrary order
+            document.Text.String = """
 ; dragon curve
 TO x n
 IF n = 0 [ STOP ]
@@ -85,13 +84,12 @@ END
 PICTURE ; start new line draw
 x 3 ; draw only a few levels
 """
-        self.logo("run")
-        # wait for LibreLogo program termination
-        while xIsAlive.invoke((), (), ())[0]:
-            pass
-        # new shape + previous two ones = 3
-        self.assertEqual(document.DrawPage.getCount(), 3)
+            self.logo("run")
+            # wait for LibreLogo program termination
+            while xIsAlive.invoke((), (), ())[0]:
+                pass
+            # new shape + previous two ones = 3
+            self.assertEqual(document.DrawPage.getCount(), 3)
 
-        self.ui_test.close_doc()
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/macro_tests/tdf124413.py b/sw/qa/uitest/macro_tests/tdf124413.py
index a81faffbb34f..b2577267b803 100644
--- a/sw/qa/uitest/macro_tests/tdf124413.py
+++ b/sw/qa/uitest/macro_tests/tdf124413.py
@@ -12,33 +12,32 @@ class tdf124413(UITestCase):
 
     def test_copy_paste_overwriting_undo_redo_in_macro_editor_tdf124413(self):
 
-        self.ui_test.create_doc_in_start_center("writer")
-        #Start LibreOffice. Go to Tools > Macros > Organize Macros > Basic
-        with self.ui_test.execute_dialog_through_command(".uno:MacroDialog", close_button="") as xDialog:
-            #Open Editor
-            xEditBtn = xDialog.getChild("edit")
-            xEditBtn.executeAction("CLICK", tuple())
-
-            resultText = "REM  *****  BASIC  *****\n\nSub Main\n\nEnd Sub\n"
-
-            xMacroWin = self.xUITest.getTopFocusWindow()
-            xEditWin = xMacroWin.getChild('EditorWindow')
-
-            self.assertEqual(get_state_as_dict(xEditWin)['Text'], resultText)
-
-            self.xUITest.executeCommand(".uno:SelectAll")
-            self.xUITest.executeCommand(".uno:Copy")
-            self.xUITest.executeCommand(".uno:SelectAll")
-            self.xUITest.executeCommand(".uno:Paste")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:Redo")
-
-            self.assertEqual(get_state_as_dict(xEditWin)['Text'], resultText)
-
-        self.ui_test.close_doc()
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
+            #Start LibreOffice. Go to Tools > Macros > Organize Macros > Basic
+            with self.ui_test.execute_dialog_through_command(".uno:MacroDialog", close_button="") as xDialog:
+                #Open Editor
+                xEditBtn = xDialog.getChild("edit")
+                xEditBtn.executeAction("CLICK", tuple())
+
+                resultText = "REM  *****  BASIC  *****\n\nSub Main\n\nEnd Sub\n"
+
+                xMacroWin = self.xUITest.getTopFocusWindow()
+                xEditWin = xMacroWin.getChild('EditorWindow')
+
+                self.assertEqual(get_state_as_dict(xEditWin)['Text'], resultText)
+
+                self.xUITest.executeCommand(".uno:SelectAll")
+                self.xUITest.executeCommand(".uno:Copy")
+                self.xUITest.executeCommand(".uno:SelectAll")
+                self.xUITest.executeCommand(".uno:Paste")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:Redo")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:Redo")
+                self.xUITest.executeCommand(".uno:Undo")
+                self.xUITest.executeCommand(".uno:Redo")
+
+                self.assertEqual(get_state_as_dict(xEditWin)['Text'], resultText)
+
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/macro_tests/tdf64690.py b/sw/qa/uitest/macro_tests/tdf64690.py
index 26a7bc949131..a764185646a1 100644
--- a/sw/qa/uitest/macro_tests/tdf64690.py
+++ b/sw/qa/uitest/macro_tests/tdf64690.py
@@ -13,60 +13,59 @@ class tdf64690(UITestCase):
 
     def test_tdf64690(self):
 
-        self.ui_test.create_doc_in_start_center("writer")
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
 
-        with self.ui_test.execute_dialog_through_command(".uno:MacroDialog", close_button="edit"):
-            pass
+            with self.ui_test.execute_dialog_through_command(".uno:MacroDialog", close_button="edit"):
+                pass
 
-        xMacroWin = self.xUITest.getTopFocusWindow()
-        xEditWin = xMacroWin.getChild('EditorWindow')
+            xMacroWin = self.xUITest.getTopFocusWindow()
+            xEditWin = xMacroWin.getChild('EditorWindow')
 
-        self.xUITest.executeCommand(".uno:SelectAll")
-        xEditWin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+            self.xUITest.executeCommand(".uno:SelectAll")
+            xEditWin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
 
-        self.assertEqual("\n", get_state_as_dict(xEditWin)['Text'])
+            self.assertEqual("\n", get_state_as_dict(xEditWin)['Text'])
 
-        xEditWin.executeAction("TYPE", mkPropertyValues({"TEXT":"'abc"}))
-        xEditWin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
-        xEditWin.executeAction("TYPE", mkPropertyValues({"TEXT":"'def"}))
+            xEditWin.executeAction("TYPE", mkPropertyValues({"TEXT":"'abc"}))
+            xEditWin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
+            xEditWin.executeAction("TYPE", mkPropertyValues({"TEXT":"'def"}))
 
-        self.assertEqual("'abc\n'def\n", get_state_as_dict(xEditWin)['Text'])
+            self.assertEqual("'abc\n'def\n", get_state_as_dict(xEditWin)['Text'])
 
-        self.xUITest.executeCommand(".uno:SelectAll")
+            self.xUITest.executeCommand(".uno:SelectAll")
 
-        self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
-        xDialog = self.xUITest.getTopFocusWindow()
+            self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+            xDialog = self.xUITest.getTopFocusWindow()
 
-        searchterm = xDialog.getChild("searchterm")
-        searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
-        searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
-        searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"."}))
+            searchterm = xDialog.getChild("searchterm")
+            searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+            searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+            searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"."}))
 
-        replaceterm = xDialog.getChild("replaceterm")
-        replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"ABC"}))
+            replaceterm = xDialog.getChild("replaceterm")
+            replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"ABC"}))
 
-        regexp = xDialog.getChild("regexp")
-        if get_state_as_dict(regexp)['Selected'] == 'false':
-            regexp.executeAction("CLICK", tuple())
-        self.assertEqual("true", get_state_as_dict(regexp)['Selected'])
+            regexp = xDialog.getChild("regexp")
+            if get_state_as_dict(regexp)['Selected'] == 'false':
+                regexp.executeAction("CLICK", tuple())
+            self.assertEqual("true", get_state_as_dict(regexp)['Selected'])
 
-        selection = xDialog.getChild("selection")
-        if get_state_as_dict(selection)['Selected'] == 'false':
-            selection.executeAction("CLICK", tuple())
-        self.assertEqual("true", get_state_as_dict(selection)['Selected'])
+            selection = xDialog.getChild("selection")
+            if get_state_as_dict(selection)['Selected'] == 'false':
+                selection.executeAction("CLICK", tuple())
+            self.assertEqual("true", get_state_as_dict(selection)['Selected'])
 
-        replaceall = xDialog.getChild("replaceall")
+            replaceall = xDialog.getChild("replaceall")
 
-        # Without the fix in place, this test would have hung here
-        with self.ui_test.execute_blocking_action(replaceall.executeAction, args=('CLICK', ())):
-            pass
+            # Without the fix in place, this test would have hung here
+            with self.ui_test.execute_blocking_action(replaceall.executeAction, args=('CLICK', ())):
+                pass
 
-        xcloseBtn = xDialog.getChild("close")
-        self.ui_test.close_dialog_through_button(xcloseBtn)
+            xcloseBtn = xDialog.getChild("close")
+            self.ui_test.close_dialog_through_button(xcloseBtn)
 
-        self.assertEqual("ABCABCABCABC\nABCABCABCABC\n", get_state_as_dict(xEditWin)['Text'])
+            self.assertEqual("ABCABCABCABC\nABCABCABCABC\n", get_state_as_dict(xEditWin)['Text'])
 
-        self.ui_test.close_doc()
 
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/navigator/tdf137274.py b/sw/qa/uitest/navigator/tdf137274.py
index 36f25f4c2d7a..b37d6413160b 100644
--- a/sw/qa/uitest/navigator/tdf137274.py
+++ b/sw/qa/uitest/navigator/tdf137274.py
@@ -12,54 +12,53 @@ class tdf137274(UITestCase):
 
     def test_tdf137274(self):
 
-        xMainDoc = self.ui_test.create_doc_in_start_center("writer")
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
 
-        xMainWindow = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xMainWindow.getChild("writer_edit")
+            xMainWindow = self.xUITest.getTopFocusWindow()
+            xWriterEdit = xMainWindow.getChild("writer_edit")
 
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Test"}))
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Test"}))
 
-        # Insert first comment
-        xArgs = mkPropertyValues({"Text": "C1"})
-        self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs)
+            # Insert first comment
+            xArgs = mkPropertyValues({"Text": "C1"})
+            self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs)
 
-        # wait until the comment is available
-        self.ui_test.wait_until_child_is_available('Comment1')
+            # wait until the comment is available
+            self.ui_test.wait_until_child_is_available('Comment1')
 
-        self.xUITest.executeCommand(".uno:Sidebar")
+            self.xUITest.executeCommand(".uno:Sidebar")
 
-        xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
+            xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
 
-        # wait until the navigator panel is available
-        xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel')
+            # wait until the navigator panel is available
+            xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel')
 
-        xContentTree = xNavigatorPanel.getChild("contenttree")
-        xComments = xContentTree.getChild('10')
-        self.assertEqual('Comments', get_state_as_dict(xComments)['Text'])
+            xContentTree = xNavigatorPanel.getChild("contenttree")
+            xComments = xContentTree.getChild('10')
+            self.assertEqual('Comments', get_state_as_dict(xComments)['Text'])
 
-        xComments.executeAction("EXPAND", tuple())
+            xComments.executeAction("EXPAND", tuple())
 
-        self.assertEqual(1, len(xComments.getChildren()))
-        self.assertEqual('C1', get_state_as_dict(xComments.getChild('0'))['Text'])
+            self.assertEqual(1, len(xComments.getChildren()))
+            self.assertEqual('C1', get_state_as_dict(xComments.getChild('0'))['Text'])
 
-        xComments.executeAction("COLLAPSE", tuple())
+            xComments.executeAction("COLLAPSE", tuple())
 
-        xArgs = mkPropertyValues({"Text": "C2"})
-        self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs)
+            xArgs = mkPropertyValues({"Text": "C2"})
+            self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs)
 
-        # wait until the second comment is available
-        self.ui_test.wait_until_child_is_available('Comment2')
+            # wait until the second comment is available
+            self.ui_test.wait_until_child_is_available('Comment2')
 
-        xComments.executeAction("EXPAND", tuple())
+            xComments.executeAction("EXPAND", tuple())
 
-        # Without the fix in place, this test would have failed with AssertionError: 2 != 0
-        self.assertEqual(2, len(xComments.getChildren()))
-        self.assertEqual('C1', get_state_as_dict(xComments.getChild('0'))['Text'])
+            # Without the fix in place, this test would have failed with AssertionError: 2 != 0
+            self.assertEqual(2, len(xComments.getChildren()))
+            self.assertEqual('C1', get_state_as_dict(xComments.getChild('0'))['Text'])
 
-        xComments.executeAction("COLLAPSE", tuple())
+            xComments.executeAction("COLLAPSE", tuple())
 
-        self.xUITest.executeCommand(".uno:Sidebar")
+            self.xUITest.executeCommand(".uno:Sidebar")
 
-        self.ui_test.close_doc()
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/navigator/tdf140257.py b/sw/qa/uitest/navigator/tdf140257.py
index 24bc177d47d7..b7b5e7aefa3c 100644
--- a/sw/qa/uitest/navigator/tdf140257.py
+++ b/sw/qa/uitest/navigator/tdf140257.py
@@ -24,89 +24,87 @@ class Tdf140257(UITestCase):
 
 
   def test_tdf140257(self):
-    self.ui_test.create_doc_in_start_center("writer")
-    xMainWindow = self.xUITest.getTopFocusWindow()
-    xWriterEdit = xMainWindow.getChild("writer_edit")
+    with self.ui_test.create_doc_in_start_center_guarded("writer") as document:
+        xMainWindow = self.xUITest.getTopFocusWindow()
+        xWriterEdit = xMainWindow.getChild("writer_edit")
 
-    self.change_outline_level("Level 1")
+        self.change_outline_level("Level 1")
 
-    for i in range(4):
-        type_text(xWriterEdit, 'P' + str(i + 1))
-        xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+        for i in range(4):
+            type_text(xWriterEdit, 'P' + str(i + 1))
+            xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
 
-    type_text(xWriterEdit, 'P5')
+        type_text(xWriterEdit, 'P5')
 
-    self.xUITest.executeCommand(".uno:Sidebar")
+        self.xUITest.executeCommand(".uno:Sidebar")
 
-    xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
+        xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
 
-    # wait until the navigator panel is available
-    xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel')
+        # wait until the navigator panel is available
+        xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel')
 
-    xContentTree = xNavigatorPanel.getChild("contenttree")
-    xHeadings = xContentTree.getChild('0')
-    self.assertEqual('Headings', get_state_as_dict(xHeadings)['Text'])
+        xContentTree = xNavigatorPanel.getChild("contenttree")
+        xHeadings = xContentTree.getChild('0')
+        self.assertEqual('Headings', get_state_as_dict(xHeadings)['Text'])
 
-    xHeadings.executeAction("EXPAND", tuple())
+        xHeadings.executeAction("EXPAND", tuple())
 
-    self.assertEqual(5, len(xHeadings.getChildren()))
+        self.assertEqual(5, len(xHeadings.getChildren()))
 
-    for i in range(5):
-        self.assertEqual('P' + str(i + 1), get_state_as_dict(xHeadings.getChild(str(i)))['Text'])
+        for i in range(5):
+            self.assertEqual('P' + str(i + 1), get_state_as_dict(xHeadings.getChild(str(i)))['Text'])
 
-    self.xUITest.executeCommand(".uno:Sidebar")
+        self.xUITest.executeCommand(".uno:Sidebar")
 
-    document = self.ui_test.get_component()
-    cursor = document.getCurrentController().getViewCursor()
+        cursor = document.getCurrentController().getViewCursor()
 
-    # Use Adding Selection
-    selectionProperty = mkPropertyValues({"SelectionMode": 2})
-    self.xUITest.executeCommandWithParameters(".uno:SelectionMode", selectionProperty)
+        # Use Adding Selection
+        selectionProperty = mkPropertyValues({"SelectionMode": 2})
+        self.xUITest.executeCommandWithParameters(".uno:SelectionMode", selectionProperty)
 
-    # Go to P2 and select it
-    cursor.goUp(3, False)
-    cursor.gotoStartOfLine(False)
-    cursor.gotoEndOfLine(True)
+        # Go to P2 and select it
+        cursor.goUp(3, False)
+        cursor.gotoStartOfLine(False)
+        cursor.gotoEndOfLine(True)
 
-    # Go to P4 and select it
-    cursor.goDown(2, False)
-    cursor.gotoStartOfLine(False)
-    cursor.gotoEndOfLine(True)
+        # Go to P4 and select it
+        cursor.goDown(2, False)
+        cursor.gotoStartOfLine(False)
+        cursor.gotoEndOfLine(True)
 
-    self.change_outline_level("Level 2")
+        self.change_outline_level("Level 2")
 
-    self.xUITest.executeCommand(".uno:Sidebar")
+        self.xUITest.executeCommand(".uno:Sidebar")
 
-    xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
+        xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
 
-    # wait until the navigator panel is available
-    xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel')
+        # wait until the navigator panel is available
+        xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel')
 
-    xContentTree = xNavigatorPanel.getChild("contenttree")
-    xHeadings = xContentTree.getChild('0')
-    self.assertEqual('Headings', get_state_as_dict(xHeadings)['Text'])
+        xContentTree = xNavigatorPanel.getChild("contenttree")
+        xHeadings = xContentTree.getChild('0')
+        self.assertEqual('Headings', get_state_as_dict(xHeadings)['Text'])
 
-    xHeadings.executeAction("EXPAND", tuple())
+        xHeadings.executeAction("EXPAND", tuple())
 
-    # Without the fix in place, this test would have failed with
-    # AssertionError: 3 != 4
-    self.assertEqual(3, len(xHeadings.getChildren()))
-    xChild1 = xHeadings.getChild('0')
-    self.assertEqual('P1', get_state_as_dict(xChild1)['Text'])
-    xChild1.executeAction("EXPAND", tuple())
-    self.assertEqual(1, len(xChild1.getChildren()))
-    self.assertEqual('P2', get_state_as_dict(xChild1.getChild('0'))['Text'])
+        # Without the fix in place, this test would have failed with
+        # AssertionError: 3 != 4
+        self.assertEqual(3, len(xHeadings.getChildren()))
+        xChild1 = xHeadings.getChild('0')
+        self.assertEqual('P1', get_state_as_dict(xChild1)['Text'])
+        xChild1.executeAction("EXPAND", tuple())
+        self.assertEqual(1, len(xChild1.getChildren()))
+        self.assertEqual('P2', get_state_as_dict(xChild1.getChild('0'))['Text'])
 
-    xChild2 = xHeadings.getChild('1')
-    self.assertEqual('P3', get_state_as_dict(xChild2)['Text'])
-    xChild2.executeAction("EXPAND", tuple())
-    self.assertEqual(1, len(xChild2.getChildren()))
-    self.assertEqual('P4', get_state_as_dict(xChild2.getChild('0'))['Text'])
+        xChild2 = xHeadings.getChild('1')
+        self.assertEqual('P3', get_state_as_dict(xChild2)['Text'])
+        xChild2.executeAction("EXPAND", tuple())
+        self.assertEqual(1, len(xChild2.getChildren()))
+        self.assertEqual('P4', get_state_as_dict(xChild2.getChild('0'))['Text'])
 
-    self.assertEqual('P5', get_state_as_dict(xHeadings.getChild('2'))['Text'])
+        self.assertEqual('P5', get_state_as_dict(xHeadings.getChild('2'))['Text'])
 
-    self.xUITest.executeCommand(".uno:Sidebar")
+        self.xUITest.executeCommand(".uno:Sidebar")
 
-    self.ui_test.close_doc()
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/options/optionsDialog.py b/sw/qa/uitest/options/optionsDialog.py
index c7bbcf71ec49..20099df1a2d7 100644
--- a/sw/qa/uitest/options/optionsDialog.py
+++ b/sw/qa/uitest/options/optionsDialog.py
@@ -9,44 +9,42 @@ from uitest.framework import UITestCase
 class optionsDialog(UITestCase):
 
     def test_moreIconsDialog(self):
-        self.ui_test.create_doc_in_start_center("writer")
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
 
-        with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog:
+            with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog:
 
-            xPages = xDialog.getChild("pages")
-            xLOEntry = xPages.getChild('0')
-            xLOEntry.executeAction("EXPAND", tuple())
-            xViewEntry = xLOEntry.getChild('2')
-            xViewEntry.executeAction("SELECT", tuple())
+                xPages = xDialog.getChild("pages")
+                xLOEntry = xPages.getChild('0')
+                xLOEntry.executeAction("EXPAND", tuple())
+                xViewEntry = xLOEntry.getChild('2')
+                xViewEntry.executeAction("SELECT", tuple())
 
-            xMoreIconsBtn = xDialog.getChild("btnMoreIcons")
+                xMoreIconsBtn = xDialog.getChild("btnMoreIcons")
 
-            with self.ui_test.execute_blocking_action(xMoreIconsBtn.executeAction, args=('CLICK', ()), close_button="buttonClose") as dialog:
-                # Check it doesn't crash while opening it
-                xCloseBtn = dialog.getChild("buttonClose")
-                self.ui_test.wait_until_property_is_updated(xCloseBtn, "Enabled", "true")
+                with self.ui_test.execute_blocking_action(xMoreIconsBtn.executeAction, args=('CLICK', ()), close_button="buttonClose") as dialog:
+                    # Check it doesn't crash while opening it
+                    xCloseBtn = dialog.getChild("buttonClose")
+                    self.ui_test.wait_until_property_is_updated(xCloseBtn, "Enabled", "true")
 
 
-        self.ui_test.close_doc()
 
     def test_tdf138596(self):
-        self.ui_test.create_doc_in_start_center("writer")
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
 
-        with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog:
-            xPages = xDialog.getChild("pages")
-            xWriterEntry = xPages.getChild('3')
-            xWriterEntry.executeAction("EXPAND", tuple())
-            xFormattingAidsEntry = xWriterEntry.getChild('2')
-            xFormattingAidsEntry.executeAction("SELECT", tuple())
+            with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog:
+                xPages = xDialog.getChild("pages")
+                xWriterEntry = xPages.getChild('3')
+                xWriterEntry.executeAction("EXPAND", tuple())
+                xFormattingAidsEntry = xWriterEntry.getChild('2')
+                xFormattingAidsEntry.executeAction("SELECT", tuple())
 
-            xApplyBtn = xDialog.getChild("apply")
+                xApplyBtn = xDialog.getChild("apply")
 
-            # Click apply button twice
-            # Without the fix in place, this test would have crashed here
-            xApplyBtn.executeAction("CLICK", tuple())
-            xApplyBtn.executeAction("CLICK", tuple())
+                # Click apply button twice
+                # Without the fix in place, this test would have crashed here
+                xApplyBtn.executeAction("CLICK", tuple())
+                xApplyBtn.executeAction("CLICK", tuple())
 
 
-        self.ui_test.close_doc()
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/options/tdf131581.py b/sw/qa/uitest/options/tdf131581.py
index 0c59f076cdf3..aab3865dc51d 100644
--- a/sw/qa/uitest/options/tdf131581.py
+++ b/sw/qa/uitest/options/tdf131581.py
@@ -10,26 +10,25 @@ from uitest.framework import UITestCase
 class tdf131581(UITestCase):
 
     def test_tdf131581(self):
-        self.ui_test.create_doc_in_start_center("writer")
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
 
-        self.xUITest.getTopFocusWindow()
+            self.xUITest.getTopFocusWindow()
 
-        with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt:
+            with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt:
 
-            xPages = xDialogOpt.getChild("pages")
-            xLOEntry = xPages.getChild('0')
-            xLOEntry.executeAction("EXPAND", tuple())
-            xAdvancedEntry = xLOEntry.getChild('10')
-            xAdvancedEntry.executeAction("SELECT", tuple())
+                xPages = xDialogOpt.getChild("pages")
+                xLOEntry = xPages.getChild('0')
+                xLOEntry.executeAction("EXPAND", tuple())
+                xAdvancedEntry = xLOEntry.getChild('10')
+                xAdvancedEntry.executeAction("SELECT", tuple())
 
-            xExpertBtn = xDialogOpt.getChild("expertconfig")
+                xExpertBtn = xDialogOpt.getChild("expertconfig")
 
-            with self.ui_test.execute_blocking_action(xExpertBtn.executeAction, args=('CLICK', ())) as dialog:
-                # Without the fix in place, this would have hung
-                xSearchBtn = dialog.getChild("searchButton")
-                xSearchBtn.executeAction("CLICK", tuple())
+                with self.ui_test.execute_blocking_action(xExpertBtn.executeAction, args=('CLICK', ())) as dialog:
+                    # Without the fix in place, this would have hung
+                    xSearchBtn = dialog.getChild("searchButton")
+                    xSearchBtn.executeAction("CLICK", tuple())
 
 
-        self.ui_test.close_doc()
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/options/tdf78133.py b/sw/qa/uitest/options/tdf78133.py
index ac71e642d062..79b38e1f6db5 100644
--- a/sw/qa/uitest/options/tdf78133.py
+++ b/sw/qa/uitest/options/tdf78133.py
@@ -14,32 +14,30 @@ class tdf78133(UITestCase):
 
     def test_tdf78133_options_app_colors(self):
 
-        self.ui_test.create_doc_in_start_center("writer")
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        document = self.ui_test.get_component()
-        #New text document
-        #open option, go to App colors
-        with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog:
+        with self.ui_test.create_doc_in_start_center_guarded("writer") as document:
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            #New text document
+            #open option, go to App colors
+            with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog:
 
-            xPages = xDialog.getChild("pages")
-            xLOEntry = xPages.getChild('0')                 # Lo Dev
-            xLOEntry.executeAction("EXPAND", tuple())
-            xLoAppColorsEntry = xLOEntry.getChild('8')
-            xLoAppColorsEntry.executeAction("SELECT", tuple())          #Applications Colors
-            #change text boundaries checkbox, save
-            docboundaries = xDialog.getChild("docboundaries")
-            docboundaries.executeAction("CLICK", tuple())
-        #verify - reopen dialog and check if "text boundaries" is still unchecked
-        with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog:
+                xPages = xDialog.getChild("pages")
+                xLOEntry = xPages.getChild('0')                 # Lo Dev
+                xLOEntry.executeAction("EXPAND", tuple())
+                xLoAppColorsEntry = xLOEntry.getChild('8')
+                xLoAppColorsEntry.executeAction("SELECT", tuple())          #Applications Colors
+                #change text boundaries checkbox, save
+                docboundaries = xDialog.getChild("docboundaries")
+                docboundaries.executeAction("CLICK", tuple())
+            #verify - reopen dialog and check if "text boundaries" is still unchecked
+            with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog:
 
-            xPages = xDialog.getChild("pages")
-            xLOEntry = xPages.getChild('0')                 # Lo Dev
-            xLOEntry.executeAction("EXPAND", tuple())
-            xLoAppColorsEntry = xLOEntry.getChild('8')
-            xLoAppColorsEntry.executeAction("SELECT", tuple())          #Applications Colors
-            #change text boundaries checkbox, save
-            docboundaries = xDialog.getChild("docboundaries")
-            self.assertEqual(get_state_as_dict(docboundaries)["Selected"], "false")
+                xPages = xDialog.getChild("pages")
+                xLOEntry = xPages.getChild('0')                 # Lo Dev
+                xLOEntry.executeAction("EXPAND", tuple())
+                xLoAppColorsEntry = xLOEntry.getChild('8')
+                xLoAppColorsEntry.executeAction("SELECT", tuple())          #Applications Colors
+                #change text boundaries checkbox, save
+                docboundaries = xDialog.getChild("docboundaries")
+                self.assertEqual(get_state_as_dict(docboundaries)["Selected"], "false")
 
-        self.ui_test.close_doc()
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/sidebar/stylesSidebar.py b/sw/qa/uitest/sidebar/stylesSidebar.py
index 7480c8008d78..8a7a7a5b1e92 100644
--- a/sw/qa/uitest/sidebar/stylesSidebar.py
+++ b/sw/qa/uitest/sidebar/stylesSidebar.py
@@ -12,61 +12,60 @@ from libreoffice.uno.propertyvalue import mkPropertyValues
 class StylesSidebar(UITestCase):
 
    def test_load_styles_from_template(self):
-        self.ui_test.create_doc_in_start_center("writer")
+        with self.ui_test.create_doc_in_start_center_guarded("writer"):
 
-        with self.ui_test.execute_dialog_through_command(".uno:LoadStyles", close_button="") as xDialog:
-            xText = xDialog.getChild("text")
-            xNumbering = xDialog.getChild("numbering")
-            xFrame = xDialog.getChild("frame")
-            xPages = xDialog.getChild("pages")
+            with self.ui_test.execute_dialog_through_command(".uno:LoadStyles", close_button="") as xDialog:
+                xText = xDialog.getChild("text")
+                xNumbering = xDialog.getChild("numbering")
+                xFrame = xDialog.getChild("frame")
+                xPages = xDialog.getChild("pages")
 
-            self.assertEqual('true', get_state_as_dict(xText)['Selected'])
-            self.assertEqual('false', get_state_as_dict(xNumbering)['Selected'])
-            self.assertEqual('false', get_state_as_dict(xFrame)['Selected'])
-            self.assertEqual('false', get_state_as_dict(xPages)['Selected'])
+                self.assertEqual('true', get_state_as_dict(xText)['Selected'])
+                self.assertEqual('false', get_state_as_dict(xNumbering)['Selected'])
+                self.assertEqual('false', get_state_as_dict(xFrame)['Selected'])
+                self.assertEqual('false', get_state_as_dict(xPages)['Selected'])
 
-            xNumbering.executeAction("CLICK", tuple())
-            xFrame.executeAction("CLICK", tuple())
-            xPages.executeAction("CLICK", tuple())
+                xNumbering.executeAction("CLICK", tuple())
+                xFrame.executeAction("CLICK", tuple())
+                xPages.executeAction("CLICK", tuple())
 
-            self.assertEqual('true', get_state_as_dict(xText)['Selected'])
-            self.assertEqual('true', get_state_as_dict(xNumbering)['Selected'])
-            self.assertEqual('true', get_state_as_dict(xFrame)['Selected'])
-            self.assertEqual('true', get_state_as_dict(xPages)['Selected'])
+                self.assertEqual('true', get_state_as_dict(xText)['Selected'])
+                self.assertEqual('true', get_state_as_dict(xNumbering)['Selected'])
+                self.assertEqual('true', get_state_as_dict(xFrame)['Selected'])
+                self.assertEqual('true', get_state_as_dict(xPages)['Selected'])
 
-            xFileName = xDialog.getChild("fromfile")
+                xFileName = xDialog.getChild("fromfile")
 
-            with self.ui_test.execute_dialog_through_action(xFileName, 'CLICK', close_button="open") as dialog:
-                xFileName = dialog.getChild("file_name")
-                xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("customStyles.odt")}))
+                with self.ui_test.execute_dialog_through_action(xFileName, 'CLICK', close_button="open") as dialog:
+                    xFileName = dialog.getChild("file_name")
+                    xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("customStyles.odt")}))
 
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            xWriterEdit = xWriterDoc.getChild("writer_edit")
 
-        self.xUITest.executeCommand(".uno:Sidebar")
-        xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "StyleListPanel"}))
+            self.xUITest.executeCommand(".uno:Sidebar")
+            xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "StyleListPanel"}))
 
-        xFilter = xWriterEdit.getChild('filter')
-        select_by_text(xFilter, "Custom Styles")
+            xFilter = xWriterEdit.getChild('filter')
+            select_by_text(xFilter, "Custom Styles")
 
-        expectedResults = ["customParagraphStyle", "customCharacterStyle", "customFrameStyle",
-                "customPageStyle", "customNumberingStyle"]
+            expectedResults = ["customParagraphStyle", "customCharacterStyle", "customFrameStyle",
+                    "customPageStyle", "customNumberingStyle"]
 
-        for i in range(5):
-            xLeft = xWriterEdit.getChild('left')
+            for i in range(5):
+                xLeft = xWriterEdit.getChild('left')
 
-            #change to another style type
-            xLeft.executeAction("CLICK", mkPropertyValues({"POS": str( i )}))
+                #change to another style type
+                xLeft.executeAction("CLICK", mkPropertyValues({"POS": str( i )}))
 
-            xFlatView = xWriterEdit.getChild("flatview")
+                xFlatView = xWriterEdit.getChild("flatview")
 
-            self.assertEqual(1, len(xFlatView.getChildren()))
+                self.assertEqual(1, len(xFlatView.getChildren()))
 
-            xFlatView.getChild('0').executeAction("SELECT", tuple())
-            self.assertEqual(expectedResults[i], get_state_as_dict(xFlatView)['SelectEntryText'])
+                xFlatView.getChild('0').executeAction("SELECT", tuple())
+                self.assertEqual(expectedResults[i], get_state_as_dict(xFlatView)['SelectEntryText'])
 
-        self.xUITest.executeCommand(".uno:Sidebar")
+            self.xUITest.executeCommand(".uno:Sidebar")
 
-        self.ui_test.close_doc()
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/sidebar/tdf133189.py b/sw/qa/uitest/sidebar/tdf133189.py
index 978358f0c2fe..0c40c8c8d72c 100644
--- a/sw/qa/uitest/sidebar/tdf133189.py
+++ b/sw/qa/uitest/sidebar/tdf133189.py
@@ -11,66 +11,65 @@ from libreoffice.uno.propertyvalue import mkPropertyValues
 
 class tdf133189(UITestCase):
     def test_tdf133189(self):
-        writer_doc = self.ui_test.create_doc_in_start_center("writer")
-
-        xWriterDoc = self.xUITest.getTopFocusWindow()
-        xWriterEdit = xWriterDoc.getChild("writer_edit")
-
-        self.xUITest.executeCommand(".uno:Sidebar")
-        xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "PageStylesPanel"}))
-
-        xPaperSize = xWriterEdit.getChild('papersize')
-        xPaperWidth = xWriterEdit.getChild('paperwidth')
-        xPaperHeight = xWriterEdit.getChild('paperheight')
-        xPaperOrient = xWriterEdit.getChild('paperorientation')
-        xPaperMargin = xWriterEdit.getChild('marginLB')
-
-        #change measurement to Inches
-        change_measurement_unit(self, 'Inch')
-
-        with self.ui_test.execute_dialog_through_command(".uno:PageDialog") as xDialog:
-            tabcontrol = xDialog.getChild("tabcontrol")
-            select_pos(tabcontrol, "1")
-
-            xWidth = xDialog.getChild('spinWidth')

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list