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: