webfp / tor-browser-selenium

Tor Browser automation with Selenium.
MIT License
556 stars 99 forks source link

Intermittent "Can't load the profile" errors during initialization #62

Closed gunesacar closed 8 years ago

gunesacar commented 8 years ago

We recently had intermittent test failures on Travis due to an initialization error:

https://travis-ci.org/webfp/tor-browser-selenium/builds/152743802 https://travis-ci.org/webfp/tor-browser-selenium/builds/152723579

The error message from Selenium: Can't load the profile. Profile Dir: /tmp/tmpO7i1lL/webdriver-py-profilecopy If you specified a log_file in the FirefoxBinary constructor, check it for details

gunesacar commented 8 years ago

Checking the browser logs from the failed cases, it turns out this happens when Tor cannot bootstrap, e.g.:

Aug 18 17:19:20.000 [notice] Bootstrapped 5%: Connecting to directory server
Aug 18 17:19:20.000 [notice] Bootstrapped 10%: Finishing handshake with directory server
Aug 18 17:19:20.000 [notice] Bootstrapped 15%: Establishing an encrypted directory connection
Aug 18 17:19:20.000 [notice] Bootstrapped 20%: Asking for networkstatus consensus
Aug 18 17:19:20.000 [notice] Bootstrapped 25%: Loading networkstatus consensus
Aug 18 17:19:21.000 [notice] I learned some more directory information, but not enough to build a circuit: We have no usable consensus.

Perhaps Tor Browser waits for Tor to bootstrap, and Selenium waits for the browser to be connectable.

I ran into this problem only ~3 of 100 runs on a local PC with a good network connection. It may make sense to skip the tests that require a Tor bootstrap on Travis. In addition we may consider exposing this error (that "tor cannot bootstrap") to calling code.