Skip to content

Commit

Permalink
blackd
Browse files Browse the repository at this point in the history
  • Loading branch information
unapproachable committed Mar 19, 2021
1 parent a06ab51 commit 83bd7a6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def amazon(
log_stock_check=log_stock_check,
shipping_bypass=shipping_bypass,
alt_offers=alt_offers,
wait_on_captcha_fail=captcha_wait
wait_on_captcha_fail=captcha_wait,
)
try:
amzn_obj.run(delay=delay, test=test)
Expand Down
24 changes: 19 additions & 5 deletions stores/amazon.py
Original file line number Diff line number Diff line change
Expand Up @@ -1441,16 +1441,30 @@ def handle_captcha(self, check_presence=True):
f"Failed to solve {captcha.image_link}, lets reload and get a new captcha."
)
if self.wait_on_captcha_fail:
log.info("Will wait up to 60 seconds for user to solve captcha")
self.send("User Intervention Required - captcha check", "captcha", self.take_screenshots)
log.info(
"Will wait up to 60 seconds for user to solve captcha"
)
self.send(
"User Intervention Required - captcha check",
"captcha",
self.take_screenshots,
)
with self.wait_for_page_content_change():
timeout = self.get_timeout(timeout=60)
while time.time() < timeout and self.driver.title == current_page:
while (
time.time() < timeout
and self.driver.title == current_page
):
time.sleep(0.5)
# check above is not true, then we must have passed captcha, return back to nav handler
# Otherwise refresh page to try again - either way, returning to nav page handler
if time.time() >timeout and self.driver.title == current_page:
log.info("User intervention did not occur in time - will attempt to refresh page and try again")
if (
time.time() > timeout
and self.driver.title == current_page
):
log.info(
"User intervention did not occur in time - will attempt to refresh page and try again"
)
self.driver.refresh()
return False
else:
Expand Down

0 comments on commit 83bd7a6

Please sign in to comment.