一、UI自动化将local_storage存入yaml 文件,再读取,实现免登陆
local_storage有三个参数
HomeCredit_qa_jwt\HomeCredit_qa_customerName\HomeCredit_qa_customerEmail

# 执行js脚本,获取local_storage中的各个字段
HomeCredit_qa_jwt = self.driver.execute_script('return window.localStorage.getItem("HomeCredit_qa_jwt");', "HomeCredit_qa_jwt")
HomeCredit_qa_customerName = self.driver.execute_script('return window.localStorage.getItem("HomeCredit_qa_customerName");', "HomeCredit_qa_customerName")
HomeCredit_qa_customerEmail = self.driver.execute_script('return window.localStorage.getItem("HomeCredit_qa_customerEmail");', "HomeCredit_qa_customerEmail")
#因为要存这三个key\value,拼成字典格式
local_storage = {"HomeCredit_qa_jwt":HomeCredit_qa_jwt,
"HomeCredit_qa_customerName":HomeCredit_qa_customerName, "HomeCredit_qa_cu

本文介绍了一种UI自动化方案,通过将selenium获取的local_storage数据保存到yaml文件,然后在basepage中读取这些数据,以此实现登录状态的持久化,避免每次测试都需要手动登录。该方法将登录步骤和yaml文件操作放在config文件夹中,提高了测试效率。
最低0.47元/天 解锁文章
31万+

被折叠的 条评论
为什么被折叠?



