请帮助,我是python的新手,现在得到以下错误
“ TypeError:必须使用ExampleScript14实例作为第一个参数调用unbound方法assertEqual()(改为使用str实例)”
代码如下:
class ExampleScript14(unittest.TestCase):
@classmethod
def setUpClass(cls):
super(ExampleScript14, cls).setUpClass()
cls.driver = webdriver.Chrome()
cls.driver.get(cls.url)
cls.test_click_the_username()
@classmethod
def test_click_the_username(self):
# Click the USer name
self.driver.find_element_by_link_text(variables.USER_NAME).click()
# click the Edit button
self.driver.find_element_by_id("btnSave").click()
print "Verify Edit button changed to Save button"
element = self.driver.find_element_by_id("btnSave")
element_attribute = element.get_attribute("value").encode('utf8')
print "attr:", type(element_attribute)
print "The button value is:", element_attribute
self.assertEqual("Save", element_attribute)
if __name__ == "__main__":
unittest.main()
答案 0 :(得分:1)
您test_click_the_username
不应该是classmethod
。只需删除@classmethod
装饰器就可以了。