updated the export code to handle failures of clicking ok after export
This commit is contained in:
@@ -15,7 +15,7 @@ dialog_timeout = 15
|
||||
progress_appear = 30
|
||||
progress_finish = 1800
|
||||
settle = 1.0
|
||||
confirm_timeout = 30
|
||||
confirm_timeout = 60
|
||||
|
||||
[controls]
|
||||
main_class = CSIFCAB
|
||||
|
||||
@@ -144,6 +144,30 @@ def perform_export(dlg, ctrl, timeouts):
|
||||
ok_btn.click()
|
||||
|
||||
|
||||
def dismiss_any_dialog(app, ctrl, log):
|
||||
"""Try to find and dismiss any stale confirmation or error dialog."""
|
||||
try:
|
||||
saved = app.window(title=ctrl["saved_title"], class_name=ctrl["saved_class"])
|
||||
if saved.exists(timeout=1):
|
||||
saved.child_window(title=ctrl["saved_ok_title"], class_name="Button").click()
|
||||
log(" Dismissed stale confirmation dialog.")
|
||||
time.sleep(0.5)
|
||||
except Exception:
|
||||
pass
|
||||
# Also try to dismiss any generic #32770 dialog with an OK button
|
||||
try:
|
||||
for w in app.windows():
|
||||
if w.class_name() == "#32770" and w.is_visible():
|
||||
try:
|
||||
w.child_window(title="OK", class_name="Button").click()
|
||||
log(f" Dismissed stale dialog: {w.window_text()!r}")
|
||||
time.sleep(0.5)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def wait_for_export(app, ctrl, timeouts, log):
|
||||
"""
|
||||
Wait for the full export lifecycle to complete:
|
||||
@@ -167,14 +191,37 @@ def wait_for_export(app, ctrl, timeouts, log):
|
||||
log(f" ERROR: export did not finish within {timeouts['progress_finish']}s.")
|
||||
return False
|
||||
|
||||
# Look for the confirmation dialog — try multiple times with short waits
|
||||
# since there can be a delay between progress closing and confirmation appearing.
|
||||
saved = app.window(title=ctrl["saved_title"], class_name=ctrl["saved_class"])
|
||||
try:
|
||||
saved.wait("visible ready", timeout=timeouts["confirm"])
|
||||
log(" Confirmation dialog appeared - export succeeded.")
|
||||
except timings.TimeoutError:
|
||||
# Fallback: look for any #32770 dialog that appeared (title may differ)
|
||||
log(" WARNING: expected confirmation dialog not found by title. "
|
||||
"Checking for any popup dialog...")
|
||||
found = False
|
||||
try:
|
||||
for w in app.windows():
|
||||
if w.class_name() == "#32770" and w.is_visible():
|
||||
log(f" Found dialog: {w.window_text()!r}")
|
||||
try:
|
||||
w.child_window(title="OK", class_name="Button").click()
|
||||
w.wait_not("visible", timeout=10)
|
||||
log(" Dismissed via fallback.")
|
||||
found = True
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
if not found:
|
||||
log(" ERROR: confirmation dialog never appeared. Export may have "
|
||||
"failed or produced no output.")
|
||||
return False
|
||||
log(" Export complete.")
|
||||
return True
|
||||
|
||||
try:
|
||||
saved.child_window(title=ctrl["saved_ok_title"], class_name="Button").click()
|
||||
@@ -192,6 +239,9 @@ def export_drawer(app, main, drawer_id, ctrl, timeouts, screenshot_dir, log):
|
||||
"""Full per-drawer sequence. Returns True on success."""
|
||||
log(f"Drawer {drawer_id}: starting")
|
||||
|
||||
# 0. Dismiss any stale dialogs left from a previous failure
|
||||
dismiss_any_dialog(app, ctrl, log)
|
||||
|
||||
# 1. Navigate
|
||||
if not navigate_to_drawer(main, drawer_id, ctrl, timeouts, log):
|
||||
take_screenshot(main, drawer_id, "nav_fail", screenshot_dir, log)
|
||||
|
||||
Reference in New Issue
Block a user