I have a simple test suite defined as below

from unittest import TestLoader, TestSuite, TextTestRunner
from TestScripts.LogOn import test_1
from TestScripts.FirstLog import test_2

if __name__ == "__main__":

    loader = TestLoader()
    suite1 = TestSuite((

    xrunner = TextTestRunner(verbosity=2)

When ever I run, I get below error for first test of test class test_1

 selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: None

But If I comment one of imports (either test_1 or Test_2) and avoid respective test loading to suite, work perfectly. in other words individual test working OK.

If I import both test_1 and test_2 classes, and load only one, same problem occurs i.e. disregards to test loading all imported classes were run and gets the error.

What am'I doing wrong? how to correct it?

I'm developing and running test using eclipse with PyDev

additional.... my classes are derived as below base class....

class BaseTestCase(unittest.TestCase):

    def setUp(self):
        self.driver = DRIVER

    def tearDown(self):

def getFoxDriver():
    ffdrive= webdriver.Firefox()
    return ffdrive    

DRIVER = getFoxDriver()

1 Answer 1


Looks like you might have some config that needs to be added to the the test classes that isnt being set when they are invoked by the runner. Do you have a ' main' block in the classes file that does this ? If so that won't work , the code that sets up fixtures should go in a SetupClass method.

  • added base class for test cases...I'm instantiation driver separately since need to keep driver alive for those set of test. dose that matters?
    – 1234
    Commented Mar 26, 2018 at 22:27
  • Put the call to getFoxDrivet in a SetupClass method , it's currently not in the class so invisible to the test runner
    – Amias
    Commented Mar 27, 2018 at 7:32
  • You then store DRIVER as cls.driver and use in an instance methods as self.driver
    – Amias
    Commented Mar 27, 2018 at 7:33
  • Ah , don't try to subclass unitest.testcase classes
    – Amias
    Commented Mar 27, 2018 at 11:28
  • Got it ..couldn't upvote of lack of reputation
    – 1234
    Commented Mar 27, 2018 at 23:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.