selenium - New WebDriver instance per test method? -


what's best practice fort creating webdriver instances in selenium-webdriver? once per test method, per test class or per test run?

they seem rather (very!) expensive spin up, keeping open between tests risks leaking information between test methods.

or there alternative - single webdriver instance single browser window (excluding popups), or there method starting new window/session given driver instance?

thanks matt

i've found reusing browser instances between test methods has been huge time saver when using real browsers, e.g. firefox. when running tests htmlunitdriver, there little benefit.

regarding danger of indeterministic tests, it's trade-off between totally deterministic tests , time. integration tests involve trade-offs these. if want totally deterministic integration tests should worrying clearing database/server state in between test runs.

one thing should if going reuse browser instances clear/store cookies between runs.

driver.manage().deleteallcookies(); 

i in teardown() method. if application stores data on client side you'd need clear (maybe via javascriptexecutor). application under test, should unrelated request after doing this, minimizes risk of indeterministic behaviour.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -