Open Bug 1738436 Opened 3 years ago Updated 9 months ago

"WebDriver:ExecuteScript" fails to access "localStorage" and "sessionStorage" window properties

Categories

(Remote Protocol :: Marionette, defect, P3)

Firefox 93
defect

Tracking

(Not tracked)

People

(Reporter: juliushamilton100, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Whiteboard: [webdriver:backlog])

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:93.0) Gecko/20100101 Firefox/93.0

Steps to reproduce:

from selenium import webdriver
from selenium.webdriver.firefox.webdriver.options import Options

options = Options()
options.headless = True
driver = webdriver.Firefox(options = options)

driver.get("https://www.google.com")

driver.execute_script("return sessionStorage.length")

Expected results:

3

When I call that command in my Firefox develop tools console, it returns 3 because there are 3 session storage variables.

Why doesn't Selenium get the session storage variables?

The Bugbug bot thinks this bug should belong to the 'DevTools::Storage Inspector' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Storage Inspector
Product: Firefox → DevTools

Moving to marionette rather than geckodriver

Type: enhancement → defect
Component: Storage Inspector → Marionette
Product: DevTools → Testing

Thanks a lot for your report! This is really interesting and we haven't heard about this problem before. I can actually verify that behavior when running a Marionette script and it doesn't matter which kind of sandbox, or even none is used. In all the cases Marionette sees an empty storage object:

1653027475648 Marionette DEBUG 3 <- [1,3,null,{"value":{"key":{},"getItem":{},"setItem":{},"removeItem":{},"clear":{},"length":0,"isSessionOnly":false}}]

Attaching the JS debugger I can verify that both storages are empty when executing the script in Marionette. I wonder if special permissions are needed to actually get access? We should discuss in our next triage meeting.

Blocks: webdriver
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Geckodriver does not collect local storage or session storage variables in Selenium → "WebDriver:ExecuteScript" fails to access "localStorage" and "sessionStorage" window properties
Whiteboard: [webdriver:backlog][webdriver:triage]

Even with using different sandbox types in Marionette doesn't mean we can run outside of a sandbox. And this might be the problem here. It's very unlikely that we could fix it for Marionette in the near future, but would take care of it for our WebDriver BiDi implementation.

Severity: -- → S3
Priority: -- → P3
Whiteboard: [webdriver:backlog][webdriver:triage] → [webdriver:backlog]
Product: Testing → Remote Protocol

I just checked the behavior with our WebDriver BiDi implementation and it works fine! As such I wonder if we should maybe take the effort to port the script evaluation logic to Marionette as well, which most likely will fix quite a few issues that we have with Marionette and script evaluation. Lets discuss that in the next triage meeting.

Whiteboard: [webdriver:backlog] → [webdriver:backlog][webdriver:triage]
Whiteboard: [webdriver:backlog][webdriver:triage] → [webdriver:backlog]
You need to log in before you can comment on or make changes to this bug.