Fix missing attribute in webdriver and reload loop.
This commit is contained in:
parent
ef848e6ca8
commit
1e4bb57cd8
|
@ -182,6 +182,10 @@ class Operator(wd.Firefox):
|
|||
self.username = None
|
||||
# Clean preceding session
|
||||
self.delete_all_cookies()
|
||||
# Fix incompatibility
|
||||
if not hasattr(self, "switch_to_default_content"):
|
||||
self.logger.debug("switch_to_default_content patched.")
|
||||
self.switch_to_default_content = self.switch_to.default_content
|
||||
|
||||
@safely(RETRIES)
|
||||
def login(self, user: str, password: str, force: bool = False) -> None:
|
||||
|
@ -228,11 +232,17 @@ class Operator(wd.Firefox):
|
|||
login_butt.submit()
|
||||
time.sleep(5)
|
||||
self.logger.debug("Login result: %s", self.title)
|
||||
safe_counter = 0
|
||||
while "Routine window" in self.title:
|
||||
self.logger.debug("Reloading...")
|
||||
self.refresh()
|
||||
self.logger.info("Reloaded %s", self.name)
|
||||
self.switch_to.alert.accept()
|
||||
time.sleep(0.5)
|
||||
if safe_counter > 5:
|
||||
self.logger.error("Too many reloads. Aborting.")
|
||||
raise RuntimeError("Too many reloads.")
|
||||
safe_counter += 1
|
||||
if is_present(self, '//a[contains(@class, "imgMenu_ctrl")]', self.timeout):
|
||||
self._logged_in = True
|
||||
self.logger.info("Login succeeded for user: %s", user)
|
||||
|
|
Loading…
Reference in New Issue
Block a user