tdf#135938 - Search for "insert reference" tree entry

Instead of assuming that the "insert reference" entry is always the second item of the menu tree, search for the correct child in the tree list. This commit addresses the failing build from https://gerrit.libreoffice.org/c/core/+/140985.

Change-Id: I6f0d7021ab6f632784cab85656823c69f90baf60
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145816
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
diff --git a/sw/qa/uitest/writer_tests7/tdf135938.py b/sw/qa/uitest/writer_tests7/tdf135938.py
index 013da93..00a72be 100755
--- a/sw/qa/uitest/writer_tests7/tdf135938.py
+++ b/sw/qa/uitest/writer_tests7/tdf135938.py
@@ -31,16 +31,21 @@ class tdf135938(UITestCase):
                xName.executeAction("TYPE", mkPropertyValues({"TEXT": "DEF"}))
                xInsert.executeAction("CLICK", tuple())

                # Select insert reference type
                xTreeEntry = xTreelistType.getChild('1')
                self.assertEqual(get_state_as_dict(xTreeEntry)["Text"], "Insert Reference")
                xTreeEntry.executeAction("SELECT", tuple())
                # Search for insert reference type
                xFilter = None
                for childIx in range(len(xTreelistType.getChildren())):
                    xTreeEntry = xTreelistType.getChild(childIx)
                    if get_state_as_dict(xTreeEntry)["Text"] == "Insert Reference":
                        xTreeEntry.executeAction("SELECT", tuple())
                        # Filter the cross references
                        xFilter = xDialog.getChild("filter")
                        xFilter.executeAction("TYPE", mkPropertyValues({"TEXT": "A"}))
                        # Without the fix in place, this test would have failed with
                        # AssertionError: 'ABC' != 'DEF', i.e., the text of the name field did not change
                        self.assertEqual(get_state_as_dict(xName)["Text"], "ABC")
                        break

                # Filter the cross references
                xFilter = xDialog.getChild("filter")
                xFilter.executeAction("TYPE", mkPropertyValues({"TEXT": "A"}))
                # Without the fix in place, this test would have failed with
                # AssertionError: 'ABC' != 'DEF', i.e., the text of the name field did not change
                self.assertEqual(get_state_as_dict(xName)["Text"], "ABC")
                # Check if insert reference entry was found
                self.assertFalse(xFilter is None)

# vim: set shiftwidth=4 softtabstop=4 expandtab: