From ab5b92d8c46ef070a14f54142af9e41f0b6893f5 Mon Sep 17 00:00:00 2001 From: s0nik42 Date: Tue, 7 Jan 2025 00:31:16 +0100 Subject: [PATCH] Add support for the new Website --- veolia-idf-domoticz.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/veolia-idf-domoticz.py b/veolia-idf-domoticz.py index 1d2e443..e2faf51 100755 --- a/veolia-idf-domoticz.py +++ b/veolia-idf-domoticz.py @@ -686,14 +686,14 @@ def get_file(self): self.wait_until_disappeared(By.CSS_SELECTOR, "lightning-spinner") time.sleep(1) - ### COMPORTEMENT DIFFERENT S'IL S AGIT D'UN MULTU CONTRATS + ### COMPORTEMENT DIFFERENT S'IL S AGIT D'UN MULTI CONTRATS ### OU D'UN CONTRAT UNIQUE (CLICK DIRECTEMENT SUR HISTORIQUE) self.print("Wait for MENU contrats or historique", end="") ep = EC.visibility_of_element_located( ( By.XPATH, - "//span[contains(text(), 'CONTRATS') or contains(text(), 'HISTORIQUE')]", + "//span[contains(text(), 'Contrats') or contains(text(), 'Historique')]", ) ) el = self.__wait.until( @@ -716,13 +716,14 @@ def get_file(self): self.print(st="ok") # GESTION DU PARCOURS MULTICONTRATS - if menu_type == "CONTRATS": + if menu_type == "Contrats": time.sleep(2) self.click_in_view( - By.LINK_TEXT, - str(self.configuration["veolia_contract"]), - wait_message="Select contract : %s" - % (str(self.configuration["veolia_contract"]),), + By.XPATH, + r"//div[@class='fra-contrat-table-row']//span[contains(@class, 'link')]/a[text()='" + + str(self.configuration["veolia_contract"]) + + r"']", + wait_message="Select contract : %s" % (str(self.configuration["veolia_contract"]),), click_message="Click on contract", delay=0, ) @@ -731,8 +732,9 @@ def get_file(self): ###### Click Historique ##### self.click_in_view( - By.LINK_TEXT, - "Historique", + By.XPATH, + r"//*[(self::a and text()='Historique')" + r" or (self::span and contains(text(), 'Historique'))]", wait_message="Wait for historique menu", click_message="Click on historique menu", delay=4, @@ -1073,7 +1075,7 @@ def update_device(self, csv_file): # Verify data integrity : d1 = datetime.strptime(date, "%Y-%m-%d") d2 = datetime.now() - if abs((d2 - d1).days) > 300: + if abs((d2 - d1).days) > 30: raise RuntimeError( "File contains too old data (monthly?!?): " + str(row)