Skip to content

Commit 07cd1f3

Browse files
anon-pradipdragotin
authored andcommitted
test(fix): Fix Windows test cleanup by navigating to main screen before teardown
1 parent 36a3027 commit 07cd1f3

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

test/gui/shared/scripts/bdd_hooks.py

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# manual for a complete reference of the available API.
1818
import shutil
1919
import os
20+
import squish
2021
from datetime import datetime
2122
from types import SimpleNamespace
2223

@@ -180,23 +181,34 @@ def teardown_client():
180181
# Cleanup user accounts from UI for Windows platform
181182
# It is not needed for Linux so skipping it in order to save CI time
182183
if is_windows():
183-
# remove account from UI
184-
# In Windows, removing only config and sync folders won't help
185-
# so to work around that, remove the account connection
186-
close_dialogs()
187-
close_widgets()
188-
active_widget = get_active_widget()
189-
if active_widget.objectName != names.setupWizardWindow_OCC_Wizard_SetupWizardWindow["name"]:
184+
try:
185+
close_dialogs()
186+
close_widgets()
187+
188+
# remove account from UI
189+
# In Windows, removing only config and sync folders won't help
190+
# so to work around that, remove the account connection
191+
# Navigate to main page via stack widget to access toolbar
192+
dialog_stack = squish.waitForObject(AccountSetting.DIALOG_STACK, get_config('minSyncTimeout') * 1000)
193+
if hasattr(dialog_stack, 'setCurrentIndex'):
194+
dialog_stack.setCurrentIndex(0)
195+
196+
squish.waitForObject(Toolbar.TOOLBAR_ROW, get_config('minSyncTimeout') * 1000)
197+
198+
# Remove all accounts
190199
accounts, selectors = Toolbar.get_accounts()
191-
for display_name in selectors:
192-
_, account_objects = Toolbar.get_accounts()
193-
squish.mouseClick(squish.waitForObject(account_objects[display_name]))
194-
AccountSetting.remove_account_connection()
195-
196-
# re-fetch accounts after removing from UI
197-
accounts, _ = Toolbar.get_accounts()
198-
if accounts:
199-
squish.waitForObject(AccountConnectionWizard.SERVER_ADDRESS_BOX)
200+
for display_name in list(selectors.keys()):
201+
try:
202+
_, account_objects = Toolbar.get_accounts()
203+
if display_name in account_objects:
204+
squish.mouseClick(squish.waitForObject(account_objects[display_name]))
205+
AccountSetting.remove_account_connection()
206+
except Exception as e:
207+
test.log(f"Warning: Could not remove account {display_name}: {e}")
208+
continue
209+
210+
except Exception as e:
211+
test.log(f"Error during Windows cleanup: {e}")
200212

201213
# Detach (i.e. potentially terminate) all AUTs at the end of a scenario
202214
for ctx in squish.applicationContextList():

0 commit comments

Comments
 (0)