Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for bugged items in checkout, then remove them from the ASIN list #529

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions stores/amazon.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def run(self, delay=DEFAULT_REFRESH_DELAY, test=False):
self.checkout_retry = 0
self.order_retry = 0
loop_iterations = 0
self.buttons_clicked_checkout = 0
self.great_success = False
while self.try_to_checkout:
try:
Expand All @@ -280,6 +281,13 @@ def run(self, delay=DEFAULT_REFRESH_DELAY, test=False):
if loop_iterations > DEFAULT_MAX_CHECKOUT_LOOPS:
self.fail_to_checkout_note()
self.try_to_checkout = False
if self.buttons_clicked_checkout > 1:
self.try_to_checkout = False
log.info("It's likely that this is a bugged amazon item.")
log.info(
"Removing this item from the ASIN list so it doesn't clog up the bot"
)
self.remove_asin_list(asin)
# if no items left it list, let loop end
if not self.asin_list:
continue_stock_check = False
Expand Down Expand Up @@ -1228,12 +1236,17 @@ def do_button_click(
clicked_text="Button clicked",
fail_text="Could not click button",
log_debug=False,
fromcheckout=False,
):
try:
with self.wait_for_page_content_change():
with self.wait_for_page_content_change(timeout=3):
log.info(clicking_text)
button.click()
log.info(clicked_text)
if fromcheckout:
self.buttons_clicked_checkout += 1
if self.buttons_clicked_checkout > 1:
return False
return True
except sel_exceptions.WebDriverException as e:
if log_debug:
Expand Down Expand Up @@ -1377,7 +1390,7 @@ def handle_checkout(self, test):
self.asin_list = []
else:
log.info(f"Clicking Button {button.text} to place order")
self.do_button_click(button=button)
self.do_button_click(button=button, fromcheckout=True)

@debug
def handle_order_complete(self):
Expand Down