mirror of
https://github.com/User0332/rewards-farmer.git
synced 2026-09-16 01:31:36 +00:00
match daily set activities by target instead of by position
get_daily_set_elements returned everything after the first link in the panel. The panel also carries promotional links, so position hands one back as an activity. Clicking it leaves rewards.bing.com and every element captured before that goes stale, which is the exception reported in #45. Activities always point at a Bing search, so match on that. When nothing matches it returns nothing rather than falling back to position, since clicking a promo is worse than skipping the task and complete_bing_daily_set already reports the shortfall.
This commit is contained in:
@@ -157,8 +157,28 @@ class ElementSelectionUtils:
|
||||
return self._streaks_button(3)
|
||||
|
||||
def get_daily_set_elements(self):
|
||||
# The first link in the opened panel is the progress row, not an activity.
|
||||
return self.get_sidebar_section().find_elements(By.TAG_NAME, "a")[1:]
|
||||
"""The daily set activities in the opened panel.
|
||||
|
||||
Everything after the first link is not reliably an activity. The panel
|
||||
also carries promotional links, a referral card and a Bing app promo have
|
||||
both been observed sitting between the progress row and the activities.
|
||||
Handing one of those back gets it clicked, which navigates away from
|
||||
rewards.bing.com, and every element captured beforehand then goes stale.
|
||||
|
||||
Activities always point at a Bing search, so match on that rather than on
|
||||
position. If nothing matches, return nothing: clicking a promo is worse
|
||||
than skipping the task, and the caller already reports the shortfall.
|
||||
"""
|
||||
activities = []
|
||||
|
||||
for link in self.get_sidebar_section().find_elements(By.TAG_NAME, "a"):
|
||||
try:
|
||||
if "bing.com/search" in (link.get_dom_attribute("href") or ""):
|
||||
activities.append(link)
|
||||
except StaleElementReferenceException:
|
||||
continue
|
||||
|
||||
return activities
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# explore on bing (absent in en-US, present in some other markets)
|
||||
|
||||
Reference in New Issue
Block a user