From 3835fad251da0c0196ffccef89dc7abf7ae9689c Mon Sep 17 00:00:00 2001 From: Carl Furtado Date: Thu, 20 Aug 2026 11:19:35 -0400 Subject: [PATCH] have misc card method clean up after itself --- src/rewards_tasks.py | 8 ++++++++ src/tab_utils.py | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/rewards_tasks.py b/src/rewards_tasks.py index c2e7333..4792b7a 100644 --- a/src/rewards_tasks.py +++ b/src/rewards_tasks.py @@ -99,6 +99,8 @@ class RewardsTaskUtils: self.tab_utils.switch_to_other_tab() self.tab_utils.close_all_other_tabs() + time.sleep(random.uniform(1, 2)) # allow card statuses to update + for card in explore_on_bing_links: if not self.elements.card_is_complete(card): print(f"[WARNING] Explore on Bing Card [desc={self.elements.extract_card_descriptions(card)!r}] is not complete after searching. Please check manually.") @@ -128,9 +130,12 @@ class RewardsTaskUtils: misc_cards: list[WebElement] = self.wait_for_element(self.elements.get_all_misc_cards) + scroll_times = 0 + for card in misc_cards: while not self.elements.element_is_fully_in_viewport(card): # this should work for top-down iteration ActionChains(self.driver).scroll_by_amount(0, 100).perform() + scroll_times+=1 if not self.elements.card_is_complete(card) and self.elements.get_card_point_value(card) > 0: self.move_to_and_click(card) @@ -143,6 +148,9 @@ class RewardsTaskUtils: self.tab_utils.close_all_other_tabs() + for i in range(scroll_times): + ActionChains(self.driver).scroll_by_amount(0, -100).perform() # scroll back to top of page + def complete_required_searches(self): self.switch_to_earn_page() self.wait_for_then_click(self.elements.get_points_breakdown_button) diff --git a/src/tab_utils.py b/src/tab_utils.py index ebb49c0..8448937 100644 --- a/src/tab_utils.py +++ b/src/tab_utils.py @@ -41,9 +41,13 @@ document.dispatchEvent(new Event('visibilitychange')); if handle not in exceptions and handle not in self.problematic_tabs: self.driver.switch_to.window(handle) + if self.driver.current_url == GHOST_TAB_URL: continue - try: self.driver.close() + try: + self.driver.close() + print(f"[INFO] Closed tab with handle {handle} and URL {self.driver.current_url}.") + except WebDriverException: print(f"[WARNING] Could not close tab with handle {handle}.") self.problematic_tabs.add(handle)