0

Initial setup

setUpClass creates a remote webdriver instance (because I don't want the overhead of creating a browser session per test) using Chrome, goes to the login page, enters credentials and submits the form. Afterwards it does a few things which requires being logged in.

Breaking change

I added another test, and wanted both tests to start from the same state, so I added self.driver.get('https://…') in setUp to go to the main page of the webapp. At this point both tests failed, and a screenshot showed that the session had been redirected to the login page.

Problem

It seems localStorage contents are not being persisted after logging in, and get() clears it. It looks like this may be a limitation of the remote webdriver, but the workaround presented in that article is Java-specific. Is there some way to have normal localStorage when using a remote webdriver in Python?

Workaround

Rather than using get() I instead click a link to go to the main page in tearDown. This of course makes the tests very brittle, because a single problem could break all the tests in that class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.