Selenium webdriver en python: Ré-utilisant le même navigateur web à travers les cas de tests

Python newb ici.
Je suis en train de ré-utiliser le même navigateur tout au long de mon cas de tests.
Cependant, je ne peux pas comprendre comment passer une variable globale pour faire ce travail.

Actuellement,
J'ai un main.py qui ressemble à ceci
#!C:/Python27/python.exe

import unittest
import unittest, time, re, HTMLTestRunner, cgi
import os, sys, inspect

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException

global DRIVER
DRIVER  = webdriver.Firefox()

# Make all subfolders available for importing
cmd_folder = os.path.realpath(os.path.abspath(os.path.split(inspect.getfile( inspect.currentframe() ))[0]))
if cmd_folder not in sys.path:
    sys.path.insert(0, cmd_folder)

# Import test cases
from setup.testcaseA import *
from setup.testcaseB import *

# serialize the testcases (grouping testcases)
suite = unittest.TestSuite() # setup new test suite
suite.addTest(unittest.makeSuite(testcaseA))
suite.addTest(unittest.makeSuite(testcaseB))

runner = HTMLTestRunner.HTMLTestRunner()
print "Content-Type: text/html\n" # header is required for displaying the website
runner.run(suite)

Et j'ai testcaseA.py fichier de configuration/dossier qui ressemble à ceci:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re, cgi

class testcaseA(unittest.TestCase):

    def setUp(self):
        #get global driver variable <- DOESNT WORK!
        self.driver = DRIVER            

    def testcaseA(self):
        driver = self.driver
        #Bunch of tests

    def tearDown(self):
        #self.driver.quit() <- Commented out, because I want to continue re-using the browser

testcaseB.py est fondamentalement identique à testcaseA.py

Quand je le lance main.py, j'obtiens une erreur:
ft1.1: Traceback (most recent call last):
Fichier "C:\test\setup\testcaseA.py", à la ligne 10, dans le programme d'installation
auto.pilote = PILOTE #get global pilote variable
NameError: nom global de "PILOTE" n'est pas défini

Des suggestions?

Merci!

OriginalL'auteur m0dE | 2012-05-16