It's a simple script, giving me an error. I'm running it from a command line:

scott$ python VerifyAboutPage.py chrome any

And the error is:

AttributeError: 'module' object has no attribute 'chrome'

The relevant portions of the script should be:

from selenium import webdriver
import unittest, time, re, reporting, sys

class VerifyAboutPage(unittest.TestCase):
    capabilities = None
    def setUp(self):
        driver = webdriver.Remote(desired_capabilities=self.capabilities)

    def tearDown(self):
        driver.quit()
        testreport.close()

if __name__ == "__main__":
    VerifyAboutPage.capabilities = {"browserName": sys.argv[1], "platform": sys.argv[2],}
    unittest.main()

I'm sure it's a simple error.

A complete error is required as it contains the offending line. I would guess that you would be passing a dictionary to Remote instead of browsername and platform, if you were using an data/instance attribute (self), but "capabilities" is a class attribute.

class VerifyAboutPage(unittest.TestCase):
    capabilities = None
    def setUp(self):
       driver = webdriver.Remote(desired_capabilities=self.capabilities)

Complete error is:

Traceback (most recent call last):
  File "VerifyAboutPage", line 24, in <module>
    unittest.main()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 149, in parseArgs
    self.createTests()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 158, in createTests
    self.module)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 128, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 100, in loadTestsFromName
    parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'chrome'

The line referenced ("VerifyAboutPage", line 24) is in the neighborhood of lines 14-15 above:

VerifyAboutPage.capabilities = {"browserName": sys.argv[1], "platform": sys.argv[2],}
unittest.main()

You are still using a dictionary instead of keywords. I would try passing the dictionary's "browsername" and "platform" separately instead of a dictionary as it appears that it doesn't know where "chrome" belongs.

Sorry, I'm new to Python. How would I do that?

Hello, for more information about Selenium with java visit here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.