Python 使用ReduxPersist使用Selenium登录React应用程序
对于我正在进行的一项调查,我试图以编程方式登录React web应用程序,但我不能每次都使用登录表单,我需要假装我刚刚回到该站点 该应用程序不使用会话cookie来识别登录的用户,而是混合使用IndexedDB和LocalStorage中的值 我的代码看起来像这样(很高兴在私人消息中向您提供网站名称),但无法成功登录。第二次访问网站时,selenium浏览器不会登录。你知道会出什么问题吗Python 使用ReduxPersist使用Selenium登录React应用程序,python,reactjs,selenium,react-redux,redux-persist,Python,Reactjs,Selenium,React Redux,Redux Persist,对于我正在进行的一项调查,我试图以编程方式登录React web应用程序,但我不能每次都使用登录表单,我需要假装我刚刚回到该站点 该应用程序不使用会话cookie来识别登录的用户,而是混合使用IndexedDB和LocalStorage中的值 我的代码看起来像这样(很高兴在私人消息中向您提供网站名称),但无法成功登录。第二次访问网站时,selenium浏览器不会登录。你知道会出什么问题吗 cookies = { # All cookies set by the domain. } loc
cookies = {
# All cookies set by the domain.
}
local_storage = {
# All key value pairs found in the local storage
# of a browser connected to the website.
}
driver = webdriver.Firefox()
driver.get(website_url)
time.sleep(5)
for key, value in local_storage.items():
driver.execute_script("window.localStorage.setItem('%s', '%s');" % (key, value))
for key, value in cookies.items():
driver.add_cookie({"name": key,
"value": value,
"domain":domain_url,
"path": "/"})
driver.execute_script("""
var db;
var request = window.indexedDB.open("keyval-store", 1);
request.onsuccess = function(event) {
db = request.result;
console.log("success: "+ db);
};
request.onupgradeneeded = function(event) {
var db = event.target.result;
var objectStore = db.createObjectStore("keyval");
objectStore.add(value_found_in_the_IndexedDB,"reduxPersist:user");
objectStore.add(another_value_found_in_the_IndexedDB, "reduxPersist:appSettings");
};
""")
time.sleep(5)
driver.get(website_url)
time.sleep(1)
没有您的代码,我们无法帮助您。@JohannesFilter因为缺少的只是凭据,所以我在电子邮件中向您发送了全部代码。最重要的信息是网站。