From 55c76d022cb9b0bc64fbde1b7bb13feb9fc1397d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Senart?= Date: Sun, 5 Feb 2023 18:09:15 +0100 Subject: [PATCH] The Web site has changed some component xpath. --- CHANGELOG.md | 5 +++++ pyveoliaidf/client.py | 14 ++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12fbe73..8dd78d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.1] - 2023-02-05 + +### Fixed +- The Web site has changed some component xpath. + ## [0.2.0] - 2022-10-17 ### Added diff --git a/pyveoliaidf/client.py b/pyveoliaidf/client.py index 19d82f8..6d82781 100644 --- a/pyveoliaidf/client.py +++ b/pyveoliaidf/client.py @@ -86,15 +86,15 @@ def update(self): # Wait a few for the data page load to complete time.sleep(5) - # Click on the "Jours" button : //*[@id="options-512"]/div[4]/div/lightning-button-group[2]/slot/c-icl-button-stateful[1]/button - jours_button_element = driver.find_element_by_xpath("//lightning-button-group[2]/slot/c-icl-button-stateful/button", "Historique page: 'Jours' button") + # Click on the "Jours" button. + jours_button_element = driver.find_element_by_xpath("//lightning-button-group[2]/div/slot/c-icl-button-stateful[1]/button", "Historique page: 'Jours' button") jours_button_element.click() # Wait a few for some internal refreshes. time.sleep(10) - # Click on the "Litres" button : //*[@id="options-415"]/div[4]/div/lightning-button-group[3]/slot/c-icl-button-stateful[2]/button - litres_button_element = driver.find_element_by_xpath("//lightning-button-group[3]/slot/c-icl-button-stateful[2]/button", "Historique page: 'Litres' button") + # Click on the "Litres" button. + litres_button_element = driver.find_element_by_xpath("//lightning-button-group[3]/div/slot/c-icl-button-stateful[2]/button", "Historique page: 'Litres' button") litres_button_element.click() # Wait a few for some internal refreshes. @@ -106,11 +106,13 @@ def update(self): startDate = endDate + datetime.timedelta(days=-self.__lastNDays) # Fill the start date text field. - start_date_element = driver.find_element_by_xpath("//input[@id='input-51']", "Historique page: 'Start date' text field") + start_date_element = driver.find_element_by_xpath("//input[@id='input-52']", "Historique page: 'Start date' text field") + start_date_element.clear() start_date_element.send_keys(startDate.strftime(dateFormat)) # Fill the end date text field. - end_date_element = driver.find_element_by_xpath("//input[@id='input-55']", "Historique page: 'End date' text field") + end_date_element = driver.find_element_by_xpath("//input[@id='input-56']", "Historique page: 'End date' text field") + end_date_element.clear() end_date_element.send_keys(endDate.strftime(dateFormat)) # Wait a few for some internal refreshes.