Read from html 5 local storage with selenium
c#, javascript, selenium
Solution
First of all, you should return the value, secondly you should cast the return value to a known type.
value = (String) js.executeScript("return localStorage.getItem('key')");
Problem
I am using selenium web driver in c#. when i write to local storage with JavaScript method it works fine ( i can see the values in the html page with inspect ), but if i try to read from local storage what i just wrote it returns Null. Thanks for any help . Writing (works): ``` IJavaScriptExecutor js = (IJavaScriptExecutor)driver; js.ExecuteScript("localStorage.setItem('key','value');"); ``` Reading (returns Null ): ``` Object Value= js.ExecuteScript("localStorage.getItem('key')"); ```