diff --git a/V6.py b/V6.py index dab83fc..3d9b7d5 100755 --- a/V6.py +++ b/V6.py @@ -198,6 +198,14 @@ def do_poll(): # Find each playable card and tries to click on it to earn points def all_cards(): driver = config.WebDriver.driver + + def popup_exploration(): + debug("Popup 'Explorer le programme' reçue") + rewards_box = driver.find_element_by_css_selector('[aria-label="Boîte de dialogue Récompenses"]') + close_button = driver.find_element_by_css_selector('[aria-label="Fermer"]') + close_button.click() + custom_sleep(1.5) + driver.get("https://rewards.bing.com") wait_until_visible(By.CLASS_NAME, "c-card-content", 10, driver) @@ -248,11 +256,7 @@ def all_cards(): try: card_list[i].click() except ElementClickInterceptedException: # Popup "Explorer le programme" - debug("Popup 'Explorer le programme' reçue") - rewards_box = driver.find_element_by_css_selector('[aria-label="Boîte de dialogue Récompenses"]') - close_button = driver.find_element_by_css_selector('[aria-label="Fermer"]') - close_button.click() - custom_sleep(1.5) + popup_exploration() card_list[i].click() if len(driver.window_handles) > 1: @@ -266,7 +270,12 @@ def all_cards(): if "mee-icon-AddMedium" in card_list[i].get_attribute("innerHTML"): driver.execute_script("arguments[0].scrollIntoView();", card_list[i]) - card_list[i].click() + try: + card_list[i].click() + except ElementClickInterceptedException: # Popup "Explorer le programme" + popup_exploration() + card_list[i].click() + driver.switch_to.window(driver.window_handles[1]) custom_sleep(10) log_error(f"Card {i} Can't be completed. Why MS ?")