Fix log in.

This commit is contained in:
sfigato 2019-02-18 12:19:19 +01:00 committed by blallo
parent 83f74ce799
commit cf9295bb6a
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F

View File

@ -165,16 +165,22 @@ class Operator(wd.Firefox):
self.logger.info("Forcing login: %s", user) self.logger.info("Forcing login: %s", user)
# Retrieve login page # Retrieve login page
self.get(self.base_uri) self.get(self.base_uri)
time.sleep(5)
_correct_url = "cpccchk" in self.current_url _correct_url = "cpccchk" in self.current_url
_now = datetime.now() _now = datetime.now()
_elapsed = timedelta(seconds=0) _elapsed = timedelta(seconds=0)
while not _correct_url: while (
not is_present(self, '//input[contains(@id, "_Accedi")]') and _correct_url
):
self.logger.debug("Not yet on login page: %s", self.current_url) self.logger.debug("Not yet on login page: %s", self.current_url)
time.sleep(0.5) time.sleep(0.5)
_correct_url = "cpccchk" in self.current_url _correct_url = "cpccchk" in self.current_url
_elapsed = datetime.now() - _now _elapsed = datetime.now() - _now
if _elapsed > self.timeout: if _elapsed > self.timeout:
break self.logger.error(
"Login page did not load properly: %s", self.current_url
)
return
self.logger.debug("After login get: %s", self.current_url) self.logger.debug("After login get: %s", self.current_url)
time.sleep(1) time.sleep(1)
# Username # Username
@ -187,7 +193,7 @@ class Operator(wd.Firefox):
user_form.send_keys(user) user_form.send_keys(user)
pass_form.send_keys(password) pass_form.send_keys(password)
do_it = True do_it = True
if self.debug and not force: if self.debug and not force and self.opts.headless:
_do_it = input("Really do the login? [y/n] ").lower() _do_it = input("Really do the login? [y/n] ").lower()
do_it = True if _do_it == "y" else False do_it = True if _do_it == "y" else False
if do_it: if do_it: