Skip to content

Commit

Permalink
Documentation improvements + Other small changes
Browse files Browse the repository at this point in the history
Removed unnecessary checks in the _get_recaptcha_box() method
  • Loading branch information
Xewdy444 committed Nov 28, 2023
1 parent eeb7bc0 commit e2aeb57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
17 changes: 5 additions & 12 deletions playwright_recaptcha/recaptchav2/async_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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()
Expand Down
17 changes: 5 additions & 12 deletions playwright_recaptcha/recaptchav2/sync_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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()
Expand Down

0 comments on commit e2aeb57

Please sign in to comment.