How to get the localStorage with Python and Selenium WebDriver

The python API doesn’t provide a way to directly read/write the local storage, but it can be done with execute_script. class LocalStorage: def __init__(self, driver) : self.driver = driver def __len__(self): return self.driver.execute_script(“return window.localStorage.length;”) def items(self) : return self.driver.execute_script( \ “var ls = window.localStorage, items = {}; ” \ “for (var i = 0, k; … Read more

Is there a way to increase the size of localStorage in Google Chrome to avoid QUOTA_EXCEEDED_ERR: DOM Exception 22

5MB is a hard limit and that is stupid. IndexedDB gives you ~50MB which is more reasonable. To make it easier to use try Dexie.js https://github.com/dfahlander/Dexie.js Update: Dexie.js was actually still an overkill for my simple key-value purposes so I wrote this much simpler script https://github.com/DVLP/localStorageDB with this you have 50MB and can get and … Read more

Conceptual problems with IndexedDB (relationships etc.)

I’m new to IndexedDB myself but I too have been thinking a lot about how I would use IndexedDB for purposes like this. The first thing I would suggest, if you haven’t done it already, is to look at how other key-value / document databases (CouchDB, MongoDB, etc.) work, since that’s essentially the type of … Read more

Is there any difference between: window.localStorage and localStorage?

Unless you’ve declared a variable named localStorage in a custom defined scope, they’re the same. localStorage refers to window.localStorage. In fact every variable in global namespace can be accessed as window.<variableName> For example: <script> function foo() { // here window.localStorage == localStorage } function foo2() { var localStorage = 10; // here window.localStorage != localStorage … Read more

localStorage is not defined (Angular Universal)

These steps resolved my issue: Step 1: Run this command: npm i localstorage-polyfill –save Step 2: Add these two lines in server.ts file: import ‘localstorage-polyfill’ global[‘localStorage’] = localStorage; Once you are done, run build command (eg: npm run build:serverless) All set now. Start the server again and you can see the issue is resolved. Note: … Read more

Storage event not firing

As others in the answers noted, the storage event only get picked up (by the listener) if the localStorage was changed in another browser’s tab/window (of the same app), but not within the context of the current tab. Detect storage changes in the current tab: window.addEventListener(‘storage’, console.log) window.localStorage.setItem(‘test’, ‘123’) window.dispatchEvent( new Event(‘storage’) ) // <—– … Read more

Set localstorage items before page loads in puppeteer?

You have to register localStorage item like this: await page.evaluate(() => { localStorage.setItem(‘token’, ‘example-token’); }); You should do it after page page.goto – browser must have an url to register local storage item on it. After this, enter the same page once again, this time token should be here before the page is loaded. Here … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)