""" modal.py — 模态框 helpers (Python 版) """ from .selectors import SEL def waitOpen(page, timeout=10000): """等 modal 打开 + form 字段渲染""" page.wait_for_selector(SEL["MODAL"], timeout=timeout) page.wait_for_selector( f'{SEL["MODAL"]} {SEL["FORM_ITEM"]}', timeout=timeout ) page.wait_for_timeout(200) def waitClose(page, timeout=15000): """等 modal 关闭""" page.wait_for_selector(SEL["MODAL"], state="hidden", timeout=timeout) def getErrors(page): """拿校验错误文字列表""" errs = page.locator(SEL["FORM_ITEM_ERROR"]) return errs.all_text_contents() def isOpen(page): """modal 是否可见""" return page.locator(SEL["MODAL"]).count() > 0 def getTitle(page): """拿 modal 标题 (e.g. "新增", "编辑", "提示")""" title = page.locator(".ant-modal-title").first if title.count() == 0: return "" return (title.text_content() or "").strip()