From e2aeb57de9bcba0403946d46cc0aa37ee0d42c2c Mon Sep 17 00:00:00 2001 From: Xewdy <95155966+Xewdy444@users.noreply.github.com> Date: Mon, 27 Nov 2023 22:42:53 -0600 Subject: [PATCH] Documentation improvements + Other small changes Removed unnecessary checks in the _get_recaptcha_box() method --- .../recaptchav2/async_solver.py | 17 +++++------------ playwright_recaptcha/recaptchav2/sync_solver.py | 17 +++++------------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/playwright_recaptcha/recaptchav2/async_solver.py b/playwright_recaptcha/recaptchav2/async_solver.py index 60841de..499d642 100644 --- a/playwright_recaptcha/recaptchav2/async_solver.py +++ b/playwright_recaptcha/recaptchav2/async_solver.py @@ -542,17 +542,10 @@ async def _get_recaptcha_box(self) -> AsyncRecaptchaBox: Raises ------ RecaptchaNotFoundError - If the reCAPTCHA was not found. + If the reCAPTCHA frames were not found + or if no unchecked reCAPTCHA boxes were found. """ - recaptcha_box = await AsyncRecaptchaBox.from_frames(self._page.frames) - - if ( - await recaptcha_box.checkbox.is_hidden() - and await recaptcha_box.audio_challenge_button.is_disabled() - ): - raise RecaptchaNotFoundError - - return recaptcha_box + return await AsyncRecaptchaBox.from_frames(self._page.frames) def close(self) -> None: """Remove the response listener.""" @@ -563,12 +556,12 @@ def close(self) -> None: async def recaptcha_is_visible(self) -> bool: """ - Check if the reCAPTCHA is visible. + Check if an unchecked reCAPTCHA box is visible. Returns ------- bool - Whether the reCAPTCHA is visible. + Whether an unchecked reCAPTCHA box is visible. """ try: await self._get_recaptcha_box() diff --git a/playwright_recaptcha/recaptchav2/sync_solver.py b/playwright_recaptcha/recaptchav2/sync_solver.py index fe5efeb..3c2dfdd 100644 --- a/playwright_recaptcha/recaptchav2/sync_solver.py +++ b/playwright_recaptcha/recaptchav2/sync_solver.py @@ -485,17 +485,10 @@ def _get_recaptcha_box(self) -> SyncRecaptchaBox: Raises ------ RecaptchaNotFoundError - If the reCAPTCHA was not found. + If the reCAPTCHA frames were not found + or if no unchecked reCAPTCHA boxes were found. """ - recaptcha_box = SyncRecaptchaBox.from_frames(self._page.frames) - - if ( - recaptcha_box.checkbox.is_hidden() - and recaptcha_box.audio_challenge_button.is_disabled() - ): - raise RecaptchaNotFoundError - - return recaptcha_box + return SyncRecaptchaBox.from_frames(self._page.frames) def close(self) -> None: """Remove the response listener.""" @@ -506,12 +499,12 @@ def close(self) -> None: def recaptcha_is_visible(self) -> bool: """ - Check if the reCAPTCHA is visible. + Check if an unchecked reCAPTCHA box is visible. Returns ------- bool - Whether the reCAPTCHA is visible. + Whether an unchecked reCAPTCHA box is visible. """ try: self._get_recaptcha_box()