Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

Surely someone else has run into this problem. I'm trying to figure out how to loop through Firefox, Chrome, and IE in conjunction with nose.

Right now I have:

  • "setup.cfg" file that specifies browsers
  • a "common.py" that reads from the config file
  • my actual "test.py" files that imports "common.py" and can reference global variables in it

The main trouble seems to be how to pass in the browser/driver into the setUp methods of the unittest.TestCase class.

One possible solution is to sub-class, and have a class for each browser. In that case I'm duplicating my test code three times, though, which is ugly.

Another possibility is to run nose in code. But I'm unsure how I would read the arguments from it inside my files.

share|improve this question
    
Even i have this issue, @aaron. –  Alagu Nov 5 '11 at 3:32
2  
What I ended up going was making a setup.cfg that my imported module reads from. It has a line to specify the browser. What I can do then is run nosetests each time after I changed the browser (the .cfg could be changed at the end of the tests in an autoamated fashion, of course). This doesn't really solve the problem, but it's at least more elegant than writing three test functions for each test, or doing something weird like copying the test folder three times. –  Aaron Nov 7 '11 at 18:28
    
@AaronShaver if that is your answer you may want to put it in the answer section and accept it. –  Dan Snell Jun 19 '12 at 2:49
add comment

1 Answer 1

Did you try using selenose? (this is the online document) I think this library might be the one fit you. It has something like this in setup.cfg:

[nosetests]

with-selenium-driver = true

selenium-driver = firefox

[selenium-driver:firefox]

webdriver = firefox

[selenium-driver:chrome]

webdriver = chrome

so, you can use command to run test like this:

nosetest --with-selenium-driver --selenium-driver=firefox

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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