From 726f0b11dcaaf3f27625a4a2dbcb9ddcdc73f98e Mon Sep 17 00:00:00 2001 From: gregory Date: Tue, 2 Sep 2025 09:35:20 -0400 Subject: [PATCH] add sanity check --- make_reservations.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/make_reservations.py b/make_reservations.py index 810cf97..a673fa3 100644 --- a/make_reservations.py +++ b/make_reservations.py @@ -153,8 +153,9 @@ def filter_row_by_date(reservation_row: webelement.WebElement) -> bool: rows = get_reservation_rows() -print('found ' + str(len(rows)) + ' reservations to add reservation comment to') -for i in range(0, len(rows)): +row_count = len(rows) +print('found ' + str(row_count) + ' reservations to add reservation comment to') +for i in range(0, row_count): row = rows[i] student_name = row.find_element(By.XPATH, './td[contains(@class, "cdk-column-Customer")]').get_attribute("innerText") reservation_date = row.find_element(By.XPATH, './td[contains(@class, "cdk-column-date")]').get_attribute("innerText") @@ -186,7 +187,7 @@ for i in range(0, len(rows)): textarea = comments.find_element(By.ID, 'comments') textarea.clear() - comment_text = "c172 " + today.strftime('%d %b, %H:%M') + comment_text = "c172 " + today.strftime('%d %b %H%M') print('comment text: ' + comment_text) textarea.send_keys(comment_text) @@ -200,5 +201,8 @@ for i in range(0, len(rows)): driver.find_element(By.XPATH, '//button[contains(@ng-click, "dismissModal()")]').click() rows = get_reservation_rows() + # If count of reservation rows changes, something is wrong + if len(rows) is not row_count: + die('reservation row count changed, aborting...') die() \ No newline at end of file