Close all browser instance in one go
<p>I am trying to close all browser instance opened by a test case in one go that is immediately when the test fails. I have opened more than one instance of same kind that is i am trying to automate chat application so i need to open two instance of same browser kind. But once the test fails, both the instance needs to be closed, but my test closes the browser for whom a particular step is failed. how to close both the browser instance when test fails for instance alone. <code>driver.quit()</code> is not working. As I have opened browser instance with different driver names i.e.</p>

<pre><code>brow1.get(url)
</code></pre>

<p>and</p>

<pre><code>brow2.get(url)
</code></pre>

<p>What about calling <code>quit()</code> for both of them</p>

<pre><code>brow1.quit();
brow2.quit();
</code></pre>

<p>Or for more generic way keep them in list and iterate over it.</p>

<pre><code>browsers = []
browsers.append(brow1)
browsers.append(brow2)

for browser in browsers:
    browser.quit()
</code></pre>

python python-2.7 selenium selenium-webdriver