|
17 | 17 | # manual for a complete reference of the available API. |
18 | 18 | import shutil |
19 | 19 | import os |
| 20 | +import squish |
20 | 21 | from datetime import datetime |
21 | 22 | from types import SimpleNamespace |
22 | 23 |
|
@@ -180,23 +181,34 @@ def teardown_client(): |
180 | 181 | # Cleanup user accounts from UI for Windows platform |
181 | 182 | # It is not needed for Linux so skipping it in order to save CI time |
182 | 183 | 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 |
190 | 199 | 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}") |
200 | 212 |
|
201 | 213 | # Detach (i.e. potentially terminate) all AUTs at the end of a scenario |
202 | 214 | for ctx in squish.applicationContextList(): |
|
0 commit comments