From c94f737b965f2496d2f321d70371557076c8f73f Mon Sep 17 00:00:00 2001 From: jdholtz Date: Wed, 3 Jul 2024 08:53:11 -0700 Subject: [PATCH] Add another debug screenshot and improve variable naming Since the driver.js_click method was added, a screenshot should be taken (if run with the --debug-screenshots) flag to more easily debug when that click fails. --- lib/fare_checker.py | 8 ++++---- lib/webdriver.py | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/fare_checker.py b/lib/fare_checker.py index 0189ab93..2b181e86 100644 --- a/lib/fare_checker.py +++ b/lib/fare_checker.py @@ -91,14 +91,14 @@ def _get_change_flight_page(self, reservation_info: JSON) -> Tuple[JSON, List[JS # Next, get the search information needed to change the flight logger.debug("Retrieving search information for the current flight") - info = reservation_info["_links"]["change"] + change_link = reservation_info["_links"]["change"] # The change link does not exist, so skip fare checking for this flight - if info is None: + if change_link is None: raise FlightChangeError("Flight cannot be changed online") - site = BOOKING_URL + info["href"] - response = make_request("GET", site, self.headers, info["query"], max_attempts=7) + site = BOOKING_URL + change_link["href"] + response = make_request("GET", site, self.headers, change_link["query"], max_attempts=7) return response["changeFlightPage"], fare_type_bounds diff --git a/lib/webdriver.py b/lib/webdriver.py index ce533230..6f3b95e5 100644 --- a/lib/webdriver.py +++ b/lib/webdriver.py @@ -146,6 +146,7 @@ def _get_driver(self) -> Driver: logger.debug("Loading Southwest home page (this may take a moment)") driver.open(BASE_URL) + self._take_debug_screenshot(driver, "after_page_load.png") driver.js_click("(//div[@data-qa='placement-link'])[2]") return driver