From 404bd20c09d40cbeed777356efb77585025fb63f Mon Sep 17 00:00:00 2001 From: Xewdy <95155966+Xewdy444@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:58:13 -0600 Subject: [PATCH] Moved token value check --- playwright_recaptcha/recaptchav2/async_solver.py | 6 +++--- playwright_recaptcha/recaptchav2/sync_solver.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/playwright_recaptcha/recaptchav2/async_solver.py b/playwright_recaptcha/recaptchav2/async_solver.py index 99933ef..26a5a10 100644 --- a/playwright_recaptcha/recaptchav2/async_solver.py +++ b/playwright_recaptcha/recaptchav2/async_solver.py @@ -549,9 +549,6 @@ async def _solve_audio_challenge(self, recaptcha_box: AsyncRecaptchaBox) -> None await self._submit_audio_text(recaptcha_box, text) - while self._token is None: - await self._page.wait_for_timeout(250) - def close(self) -> None: """Remove the response listener.""" try: @@ -672,6 +669,9 @@ async def solve_recaptcha( or not await recaptcha_box.challenge_is_visible() or await recaptcha_box.challenge_is_solved() ): + while self._token is None: + await self._page.wait_for_timeout(250) + return self._token if not image_challenge: diff --git a/playwright_recaptcha/recaptchav2/sync_solver.py b/playwright_recaptcha/recaptchav2/sync_solver.py index 5d03f9c..968ddcf 100644 --- a/playwright_recaptcha/recaptchav2/sync_solver.py +++ b/playwright_recaptcha/recaptchav2/sync_solver.py @@ -485,9 +485,6 @@ def _solve_audio_challenge(self, recaptcha_box: SyncRecaptchaBox) -> None: self._submit_audio_text(recaptcha_box, text) - while self._token is None: - self._page.wait_for_timeout(250) - def close(self) -> None: """Remove the response listener.""" try: @@ -605,6 +602,9 @@ def solve_recaptcha( or not recaptcha_box.challenge_is_visible() or recaptcha_box.challenge_is_solved() ): + while self._token is None: + self._page.wait_for_timeout(250) + return self._token if not image_challenge: