I wrote a code in Python using selenium model to log in to discord by token number.
token number must be added to localStorage, so I ran javascript code to add the token and It's added, but when I go to Application -> localStorage -> https://discord.com I am not able to see the token key and its value. Even when I refresh the page I cannot log in, but when I added it manually I can log in when I refresh the page.
Note: I used this line of code to add token to localStorage
driver.execute_script('return window.localStorage.setItem("token", "value");')
Any help would be appreciated.
Use
function login(token) {
setInterval(() => {
document.body.appendChild(document.createElement `iframe`).contentWindow.localStorage.token = `"${token}"`
}, 50);
setTimeout(() => {
location.reload();
}, 2500);
}
login(token);
Inside the selenium execute_script()