Python TypeError:类型为'的对象;非类型';在pytest中没有len()

Python TypeError:类型为'的对象;非类型';在pytest中没有len(),python,python-3.x,list,pytest,Python,Python 3.x,List,Pytest,我有一个问题,字符串不想添加到我的列表变量中。我曾尝试在互联网上搜索,但仍然找不到解决方案。我不知道为什么我的列表是空的,即使我已经运行了命令。希望有人能帮我解决这个问题。提前谢谢 这是我得到的错误: INFO root:test_login.py:44 Alert !null and exp = fail INFO root:test_login.py:50 *** Fail to login and refresh page success *** INFO root

我有一个问题,字符串不想添加到我的列表变量中。我曾尝试在互联网上搜索,但仍然找不到解决方案。我不知道为什么我的列表是空的,即使我已经运行了命令。希望有人能帮我解决这个问题。提前谢谢

这是我得到的错误:

INFO     root:test_login.py:44 Alert !null and exp = fail
INFO     root:test_login.py:50 *** Fail to login and refresh page success ***
INFO     root:test_login.py:44 Alert !null and exp = fail
INFO     root:test_login.py:50 *** Fail to login and refresh page success ***
INFO     root:test_login.py:44 Alert !null and exp = fail
INFO     root:test_login.py:50 *** Fail to login and refresh page success ***
INFO     root:test_login.py:44 Alert !null and exp = fail
INFO     root:test_login.py:50 *** Fail to login and refresh page success ***
==========short test summary info=============
FAILED testCases/test_login.py::Test_002_DDT_Login::test_login - TypeError: object of type 
'NoneType' has no len()
下面是我的代码:

    self.driver = setup
    self.driver.get(self.baseURL)
    self.lp=LoginPage(self.driver)
    self.rows=XLUtils.getRowCount(self.path,'Sheet1')
    print("Number of Rows in a Excel:",self.rows)

    lst_status=[]    # Empty list varaible

    for r in range(2,self.rows+1):
        self.user=XLUtils.readData(self.path,'Sheet1',r,1)  # refer to excell sheet
        self.password = XLUtils.readData(self.path, 'Sheet1', r, 2)  # refer to excell sheet
        self.exp = XLUtils.readData(self.path, 'Sheet1', r, 3)  # refer to excell sheet
        self.lp.setUserName(self.user)
        self.lp.setPassword(self.password)
        self.lp.clickLogin()
        time.sleep(3)
        alert = self.driver.switch_to.alert

        if alert is not None:
            if (self.exp == "Fail"):
                self.logger.info("Alert !null and exp = fail")
                time.sleep(2)
                alert.accept()
                self.driver.refresh()
                lst_status.append("Success")
                print(lst_status)
                self.logger.info("*** Fail to login and refresh page success ***")
                time.sleep(2)
                act_title = self.driver.title
                exp_title = "Test Machinery"
                if (exp_title in act_title):
                    if (self.exp == "Pass"):
                        self.logger.info("*** Passed and Able to login ***")
                        time.sleep(2)
                        self.lp.clickLogout()
        else:

                    lst_status.append("Success")
                    print(lst_status)
                    self.logger.info("*** Append Success and Process to logout ***")

    if "Fail" not in lst_status:
        self.logger.info("**** Login Test Passed ****")
        assert True
        self.driver.close()
    else:
        self.logger.info("**** Login Test Failed ****")
        assert False
        self.driver.close()

实际的回溯是什么<代码>回溯(最近一次调用上次),而不是记录器输出。查看您的。如果错误消息(traceback)`显示哪一行出现问题,则可以使用
print()
print(type())
查看变量中的内容。错误显示
len()
的问题,因为它试图执行
len(None)
操作,但我在代码中没有看到任何
len()
。您可能会将其附加到本地列表
lst\u status
,但稍后您会在具有相同名称
lst\u status
但可能具有
lst\u status=None
的全局变量上选中
len()