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

Pork shoulders #200

Merged
merged 2 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
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
26 changes: 25 additions & 1 deletion src/activities.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import contextlib
import random
import time
import logging

from selenium.common import TimeoutException
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement

from selenium.common.exceptions import NoSuchElementException, ElementNotInteractableException
from src.browser import Browser


Expand All @@ -14,6 +15,29 @@ def __init__(self, browser: Browser):
self.browser = browser
self.webdriver = browser.webdriver

def click_element_if_visible(self, element):
try:
if element.is_displayed() and element.is_enabled():
element.click()
logging.info("Dashboard pop-up registered and closed, needs to be done once on new accounts")
else:
pass
except (ElementNotInteractableException, NoSuchElementException):
pass

def dashboardPopUpModalCloseCross(self):
try:

element = self.webdriver.find_element(By.CSS_SELECTOR, ".dashboardPopUpPopUpSelectButton")
self.click_element_if_visible(element)
time.sleep(0.25)
except NoSuchElementException:
return





def openDailySetActivity(self, cardId: int):
# Open the Daily Set activity for the given cardId
element = self.webdriver.find_element(By.XPATH,
Expand Down
2 changes: 1 addition & 1 deletion src/dailySet.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import urllib.parse
from datetime import datetime

from src.browser import Browser
from .activities import Activities

Expand All @@ -17,6 +16,7 @@ def completeDailySet(self):
logging.info("[DAILY SET] " + "Trying to complete the Daily Set...")
data = self.browser.utils.getDashboardData()["dailySetPromotions"]
self.browser.utils.goToRewards()
self.activities.dashboardPopUpModalCloseCross()
todayDate = datetime.now().strftime("%m/%d/%Y")
for activity in data.get(todayDate, []):
cardId = int(activity["offerId"][-1:])
Expand Down
Loading