diff --git a/tests/system/objects.map b/tests/system/objects.map
index b39ba183f66370efddb567e1decfc5a825853399..abc6939063f4a8dd6e0370c30bf2e43033214c12 100644
--- a/tests/system/objects.map
+++ b/tests/system/objects.map
@@ -137,6 +137,8 @@
 :Restart required_QMessageBox	{text='The language change will take effect after a restart of Qt Creator.' type='QMessageBox' unnamed='1' visible='1'}
 :Revert to Saved.Proceed_QPushButton	{text='Proceed' type='QPushButton' unnamed='1' visible='1' window=':Revert to Saved_QMessageBox'}
 :Revert to Saved_QMessageBox	{text?='You will lose your current changes if you proceed reverting*' type='QMessageBox' unnamed='1' visible='1'}
+:RunSettingsEnvironmentDetails_Utils::DetailsButton	{leftWidget=':RunSettingsUseBuildEnvironment_QLabel' text='Details' type='Utils::DetailsButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
+:RunSettingsUseBuildEnvironment_QLabel	{text~='Us(e|ing) <b>Build Environment</b>' type='QLabel' unnamed='1' visible='1'}
 :Startup.contextHelpComboBox_QComboBox	{container=':Form.Startup_QGroupBox' name='contextHelpComboBox' type='QComboBox' visible='1'}
 :Symbol Server_Utils::CheckableMessageBox	{type='Utils::CheckableMessageBox' unnamed='1' visible='1' windowTitle='Symbol Server'}
 :User Interface.languageBox_QComboBox	{container=':Core__Internal__GeneralSettings.User Interface_QGroupBox' name='languageBox' type='QComboBox' visible='1'}
diff --git a/tests/system/shared/hook_utils.py b/tests/system/shared/hook_utils.py
index fca63726a1995d2974ed7afb8e15c0fe4b81fb89..1683a1dc3e6ca60d1368e5ca86d7f77e2c5eb09e 100644
--- a/tests/system/shared/hook_utils.py
+++ b/tests/system/shared/hook_utils.py
@@ -17,9 +17,7 @@ def modifyRunSettingsForHookInto(projectName, kitCount, port):
     switchToBuildOrRunSettingsFor(kitCount, 0, ProjectSettings.RUN)
     result = __configureCustomExecutable__(projectName, port, mkspec, qtVersion)
     if result:
-        clickButton(waitForObject("{window=':Qt Creator_Core::Internal::MainWindow' text='Details' "
-                                  "type='Utils::DetailsButton' unnamed='1' visible='1' "
-                                  "leftWidget={type='QLabel' text~='Us(e|ing) <b>Build Environment</b>' unnamed='1' visible='1'}}"))
+        ensureChecked(":RunSettingsEnvironmentDetails_Utils::DetailsButton")
         envVarsTableView = waitForObject("{type='QTableView' visible='1' unnamed='1'}")
         model = envVarsTableView.model()
         changingVars = []
@@ -41,17 +39,23 @@ def modifyRunSettingsForHookInto(projectName, kitCount, port):
                     changingVars.append("SQUISH_LIBQTDIR=%s" % replacement)
                 else:
                     changingVars.append(varName)
-                    #test.log("Unsetting %s for run" % varName)
-        clickButton(waitForObject("{text='Batch Edit...' type='QPushButton' unnamed='1' visible='1' "
-                                  "window=':Qt Creator_Core::Internal::MainWindow'}"))
-        editor = waitForObject("{type='TextEditor::SnippetEditorWidget' unnamed='1' visible='1' "
-                               "window=':Edit Environment_ProjectExplorer::EnvironmentItemsDialog'}")
-        typeLines(editor, changingVars)
-        clickButton(waitForObject("{text='OK' type='QPushButton' unnamed='1' visible='1' "
-                                  "window=':Edit Environment_ProjectExplorer::EnvironmentItemsDialog'}"))
+        batchEditRunEnvironment(kitCount, 0, changingVars, True)
     switchViewTo(ViewConstants.EDIT)
     return result
 
+def batchEditRunEnvironment(kitCount, currentTarget, modifications, alreadyOnRunSettings=False):
+    if not alreadyOnRunSettings:
+        switchViewTo(ViewConstants.PROJECTS)
+        switchToBuildOrRunSettingsFor(kitCount, currentTarget, ProjectSettings.RUN)
+    ensureChecked(":RunSettingsEnvironmentDetails_Utils::DetailsButton")
+    clickButton(waitForObject("{text='Batch Edit...' type='QPushButton' unnamed='1' visible='1' "
+                              "window=':Qt Creator_Core::Internal::MainWindow'}"))
+    editor = waitForObject("{type='TextEditor::SnippetEditorWidget' unnamed='1' visible='1' "
+                           "window=':Edit Environment_ProjectExplorer::EnvironmentItemsDialog'}")
+    typeLines(editor, modifications)
+    clickButton(waitForObject("{text='OK' type='QPushButton' unnamed='1' visible='1' "
+                              "window=':Edit Environment_ProjectExplorer::EnvironmentItemsDialog'}"))
+
 def modifyRunSettingsForHookIntoQtQuickUI(kitCount, workingDir, projectName, port):
     switchViewTo(ViewConstants.PROJECTS)
     switchToBuildOrRunSettingsFor(kitCount, 0, ProjectSettings.RUN, True)