Julian A.
Julian A.

Reputation: 11450

Share single instance of selenium RemoteWebDriver between multiple test cases

Are there problems with sharing a single instance of RemoteWebDriver between multiple test cases? If not, what's the best practice place to create the instance? I'm working with Python, so I think my options are module level setup, test case class setup, test case instance setup (any others?)

Upvotes: 0

Views: 330

Answers (1)

Silas Ray
Silas Ray

Reputation: 26150

Sharing a single RemoteWebDriver can be dangerous, since your tests are no longer independently self-contained. You have to be careful about cleaning up browser state and the like, and recovering from browser crashes in the event a previous test has crashed the browser. You'll also probably have more problems if you ever try to do anything distributed across multiple threads, processes, or machines. That said, the options you have for controlling this are not dependent on Selenium itself, but whatever code or framework you are using to drive it. At least with Nose, and I think basic pyunit, you can have setup routines at the class, module, or package level, and they can be configured to run for each test, each class, each module, or each package, if memory serves.

Upvotes: 1

Related Questions