Search code examples
rubycapybaragoogle-chrome-headlesspoltergeist

How do I view local storage and session storage using capybara


I'm doing some analysis to confirm what data is being stored on the client by various interactions with some websites. I'd like to automate this using Capybara (and Poltergeist / headless chrome). I can get the cookies using

@session.driver.cookies

Is there a way to do something similar for any local storage and session storage likewise? Scanning through the docs but can't find anything.


Solution

  • Poltergeist and headless chrome are different things. Poltergeist is obsolete/discontinued at this point in time, but if you're using headless chrome via the selenium driver you can access them as

    @session.driver.browser.local_storage
    @session.driver.browser.session_storage
    

    Note: This is selenium driver specific - the only cross driver method would be to access them via evaluate_script