fix: закрывать браузер в finally — после отправки hh.ru закрывает модалку, wait_for_timeout падал с TargetClosedError и _close_context пропускался
This commit is contained in:
1 parent
ec9f342cf6
commit
3d5610ca79
1 file changed
+11
-2
+11
-2
@@ -277,10 +277,15 @@ def open_response_page(account_dir, user, account, vacancy, message,
|
|||||||
if not submitted:
|
if not submitted:
|
||||||
shot = _save_screenshot(page, screenshot_dir, vacancy["id"])
|
shot = _save_screenshot(page, screenshot_dir, vacancy["id"])
|
||||||
return False, "Не нашёл кнопку «Отправить» — проверьте скриншот", shot
|
return False, "Не нашёл кнопку «Отправить» — проверьте скриншот", shot
|
||||||
# Ждём подтверждение и снимаем скриншот результата
|
# Ждём подтверждение и снимаем скриншот результата.
|
||||||
|
# После отправки hh.ru может закрыть модалку/перезагрузить страницу —
|
||||||
|
# ловим любые ошибки, но браузер закрываем ВСЕГДА (finally).
|
||||||
|
try:
|
||||||
page.wait_for_timeout(2500)
|
page.wait_for_timeout(2500)
|
||||||
shot = _save_screenshot(page, screenshot_dir, vacancy["id"])
|
shot = _save_screenshot(page, screenshot_dir, vacancy["id"])
|
||||||
# Отклик отправлен — закрываем браузер автоматически
|
except Exception:
|
||||||
|
shot = None
|
||||||
|
finally:
|
||||||
_close_context(key)
|
_close_context(key)
|
||||||
return True, "Отклик отправлен", shot
|
return True, "Отклик отправлен", shot
|
||||||
|
|
||||||
@@ -299,7 +304,11 @@ def confirm_send(user, account, vid):
|
|||||||
btn = page.locator(sel).first
|
btn = page.locator(sel).first
|
||||||
if btn.is_visible(timeout=3000):
|
if btn.is_visible(timeout=3000):
|
||||||
btn.click()
|
btn.click()
|
||||||
|
try:
|
||||||
page.wait_for_timeout(1500)
|
page.wait_for_timeout(1500)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
# Отклик отправлен — закрываем браузер автоматически
|
# Отклик отправлен — закрываем браузер автоматически
|
||||||
_close_context(key)
|
_close_context(key)
|
||||||
return True, "Кнопка «Отправить» нажата. Проверьте статус отклика на hh.ru."
|
return True, "Кнопка «Отправить» нажата. Проверьте статус отклика на hh.ru."
|
||||||
|
|||||||
Reference in new issue
Block a user