Reputation: 41
I am using selenium python webdriver for my python test cases. I have a python script NowSpots_Traffic.py which I'm trying to run from Ubuntu terminal (something similar to command prompt in windows)
python /home/vijay/Projects/SeleniumScripts/NowSpots_Traffic.py samuel secrete
where samuel and secrete are two arguments which I need to pass to my python script NowSpots_Traffic.py
I followed the instructions found at Running Tests in Python with Selenium 2 and WebDriver section "Multiple browsers and multiple platforms".
But I get the following error message
Traceback (most recent call last):
File "/home/vijay/Projects/SeleniumScripts/NowSpots_Traffic.py", line 43, in <module>
unittest.main()
File "/usr/lib/python2.7/unittest/main.py", line 94, in __init__
self.parseArgs(argv)
File "/usr/lib/python2.7/unittest/main.py", line 152, in parseArgs
self.createTests()
File "/usr/lib/python2.7/unittest/main.py", line 161, in createTests
self.module)
File "/usr/lib/python2.7/unittest/loader.py", line 128, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/usr/lib/python2.7/unittest/loader.py", line 100, in loadTestsFromName
parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'samuel'
Upvotes: 1
Views: 2366
Reputation: 2219
The Unittest.main() function uses the arguments you pass in to determine test cases to run. See here: Test Discovery
If your script also needs arguments, you will want to remove them from sys.argv before calling
unittest.main()
Upvotes: 1