前端可能会将某些数据存储到LocalStorage本地库里,方便后续的一些判断,例如百度一下
读取value
from selenium import webdriver
browser = webdriver.Chrome()
browser.get('http://www.baidu.com/')
value = browser.execute_script('return localStorage.getItem("wwwPassLogout");')
assert value == "0"
更新value
from selenium import webdriver
browser = webdriver.Chrome()
browser.get('http://www.baidu.com/')
driver.execute_script('localStorage.setItem("wwwPassLogout", "2");')
assert browser.execute_script('return localStorage.getItem("wwwPassLogout");') == "2"