Zayonx
Zayonx

Reputation: 174

Access Selenium LocalStorage nodejs

Im trying to retrieve a value from a key using selenium, i've been searching for hours without anybody or anything telling me how i could do that, What im trying to retrieve looks like this which i obtained while typing F12 : https://i.sstatic.net/ywYkL.png Which is on the client side.

Upvotes: 0

Views: 845

Answers (3)

Kizy Lírio
Kizy Lírio

Reputation: 36

You can use this:

driver.executeScript(
        "localStorage.getItem(arguments[0])", key
    );

Upvotes: 2

AEF
AEF

Reputation: 167

for who maybe still are looking for the solution:
you can use web driver executeScript

async function(localStorageFieldName){
      await driver.executeScript(function(){
         return localStorage.getItem(arguments[0])
      },localStorageFieldName)
}

reference to executeScript : link

Upvotes: 1

Andrei
Andrei

Reputation: 5647

Try this:

window.localStorage.getItem("BrowserHandoffStore");

Example here:

window.localStorage.setItem("test", false);
window.localStorage.getItem("test")

Output:

false

Upvotes: 1

Related Questions