have misc card method clean up after itself

This commit is contained in:
Carl Furtado
2026-08-20 11:19:35 -04:00
parent af2eb68940
commit 3835fad251
2 changed files with 13 additions and 1 deletions
+8
View File
@@ -99,6 +99,8 @@ class RewardsTaskUtils:
self.tab_utils.switch_to_other_tab() self.tab_utils.switch_to_other_tab()
self.tab_utils.close_all_other_tabs() 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: for card in explore_on_bing_links:
if not self.elements.card_is_complete(card): 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.") 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) misc_cards: list[WebElement] = self.wait_for_element(self.elements.get_all_misc_cards)
scroll_times = 0
for card in misc_cards: for card in misc_cards:
while not self.elements.element_is_fully_in_viewport(card): # this should work for top-down iteration 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() 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: if not self.elements.card_is_complete(card) and self.elements.get_card_point_value(card) > 0:
self.move_to_and_click(card) self.move_to_and_click(card)
@@ -143,6 +148,9 @@ class RewardsTaskUtils:
self.tab_utils.close_all_other_tabs() 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): def complete_required_searches(self):
self.switch_to_earn_page() self.switch_to_earn_page()
self.wait_for_then_click(self.elements.get_points_breakdown_button) self.wait_for_then_click(self.elements.get_points_breakdown_button)
+5 -1
View File
@@ -41,9 +41,13 @@ document.dispatchEvent(new Event('visibilitychange'));
if handle not in exceptions and handle not in self.problematic_tabs: if handle not in exceptions and handle not in self.problematic_tabs:
self.driver.switch_to.window(handle) self.driver.switch_to.window(handle)
if self.driver.current_url == GHOST_TAB_URL: continue 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: except WebDriverException:
print(f"[WARNING] Could not close tab with handle {handle}.") print(f"[WARNING] Could not close tab with handle {handle}.")
self.problematic_tabs.add(handle) self.problematic_tabs.add(handle)