我正在写一个测试脚本,遇到了这个问题:
ERROR - FAILED - ERROR Message:'NoneType' object is not iterable
代码在这里:
^{pr2}$list_object方法将返回一个两层嵌套列表。在
def list_objects(self, window):
logger.info("get objects list in window: %s" % window)
all_objects_list = self.__parse_objects(ldtp.getobjectlist(self.get_locator(window)))
logger.info("sorted all_objects_list: %s" % all_objects_list)
def __parse_objects(self, objects_list):
logger.info("parse objects list")
window_list = []
tab_list = []
button_list = []
table_list = []
text_list = []
menu_list = []
checkbox_list = []
label_list = []
others_list = []
parsed_objects_list = [window_list, tab_list, button_list, table_list, text_list, menu_list, checkbox_list, label_list, others_list]
for item in objects_list:
if item.startswith("frm") or item.startswith("dlg"):
window_list.append(item)
elif item.startswith("ptab"):
tab_list.append(item)
elif item.startswith("btn"):
button_list.append(item)
elif item.startswith("ttbl") or item.startswith("tbl"):
table_list.append(item)
elif item.startswith("txt"):
text_list.append(item)
elif item.startswith("mnu"):
menu_list.append(item)
elif item.startswith("chk"):
checkbox_list.append(item)
elif item.startswith("lbl"):
label_list.append(item)
else:
others_list.append(item)
return parsed_objects_list
但我在嵌套列表中找不到东西。在
因此,我创建了一个名为coveroff的方法,使两层列表成为一个简单列表。在
但是这个错误让我崩溃了。在
如何调试此错误?欢迎有任何想法!在
在Python中,方法中没有
return
语句与返回None
相同。因此,您的方法在您期望它返回一个列表时返回None
,因此出现错误。在相关问题 更多 >
编程相关推荐