def save_session(self, value): """ 1. 其中localStorage、token关键字是需要根据自己实际情况填写的 localStorage:目标系统,需要查看自己的token是存在localStorage中,还是sessionStorage。 我的是存在localStorage中,如上图1所示 token:变量名,需要查看自己的token所对应的变量是什么,我这里是token,如上图2所示 2. return是必须要有的, 否则返回值会为None 3. 这个方法必须放在登录的下一步就使用,如果你放在其它阶段获取出来的token是为None值的 """
while True:
token = self.driver.execute_script(f'return localStorage.getItem("{value}")')
if token:
return token