From d7d2f49a3f75acce181fb64646a05e48a843956b Mon Sep 17 00:00:00 2001 From: augustin64 Date: Fri, 12 Apr 2024 23:46:26 +0200 Subject: [PATCH] =?UTF-8?q?pas=20la=20seule=20occurrence=20=C3=A9videmment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- V6.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) 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 ?")