forked from piair/MsRewards-Reborn
welcome-tour: URL check
This commit is contained in:
parent
fcb40537dc
commit
ae023688a4
27
V6.py
27
V6.py
@ -199,12 +199,16 @@ def do_poll():
|
|||||||
def all_cards():
|
def all_cards():
|
||||||
driver = config.WebDriver.driver
|
driver = config.WebDriver.driver
|
||||||
|
|
||||||
def popup_exploration():
|
def check_welcome_tour() -> bool:
|
||||||
debug("Popup 'Explorer le programme' reçue")
|
if "rewards.bing.com/welcometour" not in driver.current_url:
|
||||||
|
return False
|
||||||
|
|
||||||
|
info("Popup 'Explorer le programme' reçue")
|
||||||
rewards_box = driver.find_element(By.CSS_SELECTOR, '[aria-label="Boîte de dialogue Récompenses"]')
|
rewards_box = driver.find_element(By.CSS_SELECTOR, '[aria-label="Boîte de dialogue Récompenses"]')
|
||||||
close_button = rewards_box.find_element(By.CSS_SELECTOR, '[aria-label="Fermer"]')
|
close_button = rewards_box.find_element(By.CSS_SELECTOR, '[aria-label="Fermer"]')
|
||||||
close_button.click()
|
close_button.click()
|
||||||
custom_sleep(1.5)
|
custom_sleep(1.5)
|
||||||
|
return True
|
||||||
|
|
||||||
driver.get("https://rewards.bing.com")
|
driver.get("https://rewards.bing.com")
|
||||||
wait_until_visible(By.CLASS_NAME, "c-card-content", 10, driver)
|
wait_until_visible(By.CLASS_NAME, "c-card-content", 10, driver)
|
||||||
@ -249,14 +253,13 @@ def all_cards():
|
|||||||
if i == len(card_list) and i > 15:
|
if i == len(card_list) and i > 15:
|
||||||
checked = False
|
checked = False
|
||||||
|
|
||||||
if checked:
|
if not checked:
|
||||||
|
continue
|
||||||
|
|
||||||
custom_sleep(1.5)
|
custom_sleep(1.5)
|
||||||
driver.execute_script("arguments[0].scrollIntoView();", card_list[i])
|
driver.execute_script("arguments[0].scrollIntoView();", card_list[i])
|
||||||
custom_sleep(1.5)
|
custom_sleep(1.5)
|
||||||
try:
|
check_welcome_tour()
|
||||||
card_list[i].click()
|
|
||||||
except ElementClickInterceptedException: # Popup "Explorer le programme"
|
|
||||||
popup_exploration()
|
|
||||||
card_list[i].click()
|
card_list[i].click()
|
||||||
|
|
||||||
if len(driver.window_handles) > 1:
|
if len(driver.window_handles) > 1:
|
||||||
@ -268,12 +271,11 @@ def all_cards():
|
|||||||
driver.refresh()
|
driver.refresh()
|
||||||
card_list = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
card_list = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
||||||
|
|
||||||
if "mee-icon-AddMedium" in card_list[i].get_attribute("innerHTML"):
|
if "mee-icon-AddMedium" not in card_list[i].get_attribute("innerHTML"):
|
||||||
|
continue
|
||||||
|
|
||||||
driver.execute_script("arguments[0].scrollIntoView();", card_list[i])
|
driver.execute_script("arguments[0].scrollIntoView();", card_list[i])
|
||||||
try:
|
check_welcome_tour()
|
||||||
card_list[i].click()
|
|
||||||
except ElementClickInterceptedException: # Popup "Explorer le programme"
|
|
||||||
popup_exploration()
|
|
||||||
card_list[i].click()
|
card_list[i].click()
|
||||||
|
|
||||||
driver.switch_to.window(driver.window_handles[1])
|
driver.switch_to.window(driver.window_handles[1])
|
||||||
@ -288,6 +290,7 @@ def all_cards():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
debug(e)
|
debug(e)
|
||||||
driver.get("https://rewards.bing.com")
|
driver.get("https://rewards.bing.com")
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
log_error(err)
|
log_error(err)
|
||||||
custom_sleep(3)
|
custom_sleep(3)
|
||||||
|
Loading…
Reference in New Issue
Block a user