From 5f704130561b8a3741d93061d930aa9b5f4951c8 Mon Sep 17 00:00:00 2001 From: Aysylu Greenberg Date: Sun, 28 Apr 2024 22:41:09 -0400 Subject: [PATCH] replaced sleep values with vars --- goportparking.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/goportparking.py b/goportparking.py index 147ad6e..443095d 100644 --- a/goportparking.py +++ b/goportparking.py @@ -10,6 +10,9 @@ import traceback import adbase as ad +JS_WAIT = 1 +WEB_WAIT = 5 + class GoPortParkingController(hass.Hass): def initialize(self): chrome_options = Options() @@ -75,7 +78,7 @@ def book_daily(self, event_name, data, kwargs): self.get_entity(entity).set_state(state='opening_portal', attributes={'detail': 'Opening portal'}) self.log(f"buying daily: navigating to login") self.driver.get("https://goportparking.org/rppportal/login.xhtml") - time.sleep(5) + time.sleep(WEB_WAIT) self.log(f"buying daily: logging in") username = self.driver.find_element(By.ID, "username") username.clear() @@ -85,7 +88,7 @@ def book_daily(self, event_name, data, kwargs): password.send_keys(self.args['password']) self.driver.find_element(By.ID, "login").click() self.get_entity(entity).set_state(state='logging_in', attributes={'detail': 'Logging in...'}) - time.sleep(5) + time.sleep(WEB_WAIT) if self.driver.current_url != 'https://goportparking.org/rppportal/index.xhtml': self.log(f"Login seems to have failed") self.get_entity(entity).set_state(state='login_failed', attributes={'detail': 'Login failed'})