我知道已经问过类似这样的问题,但是在这些问题的评论中找不到答案。请在这里帮助我。

我有以下页面对象:

class ChatInput(BaseTest):
    def __init__(self, driver, *args, **kwargs):
        super(ChatInput, self).__init__(*args, **kwargs)
        self.driver = driver

    def get_chat_Input(self):
        return self.wait_for_element_by_xpath(elements.CHAT_INPUT, 60)

    def add_content_in_chatInput(self, msg):
        chatInput = self.get_chat_Input()
        chatInput.clear()
        chatInput.click()
        chatInput.send_keys('')
        chatInput.send_keys(msg)

        return True


我正在从此页面对象调用方法到我的测试类。

from .components.ChatInput import ChatInput

class SmokeTest(BaseTest):
    def test_everything(self):
        env = self.getEnvConfig()
        for driver in env['DRIVERS']:
            self.configDriver(driver)
            self.driver.get(CONFIG.SITE_URL)

            self.chatInput = ChatInput(self.driver)

            assert self.chatInput.add_content_in_chatInput('Hello, this is agent QA. Please tell us, how we can help you today?')


但是当我运行测试时,出现以下错误:

 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/suite.py", line 84, in __call__
    return self.run(*args, **kwds)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/suite.py", line 122, in run
    test(result)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 663, in __call__
    return self.run(*args, **kwds)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 590, in run
    testMethod = getattr(self, self._testMethodName)
AttributeError: 'ChatInput' object has no attribute 'runTest'


请让我知道我在做什么错?

最佳答案

看来您正在尝试测试一种称为runTest的方法。或更具体地说,在测试时,您想运行不存在的ChatInput.runTest。这就是错误消息的意思。

07-24 15:58