我有一个用例,必须自动执行以下步骤:
反向排序列表并返回值
*** Settings ***
Library SeleniumLibrary
Library Collections
*** Keywords ***
Sort order verification
@{username_list}= Create List //creates an empty list
@{get_name}= Get WebElements css=#userTable > tbody > tr> td:nth-child(1)
:FOR ${each} IN @{get_name}
\ ${get_username}= Get Text ${each}
\ Append To List ${username_list} ${get_username} //pushes data into list in iteration
${original_order}= Copy list ${username_list} //returns original order
${sorted_list}= Sort List ${original_order} //sorts the list but returns none(nothing is saved in the variable
${reverse_sorted_list}= Reverse List ${sorted_list} //returns AttributeError: 'NoneType' object has no attribute 'reverse'
答案 0 :(得分:2)
Sort List
和Reverse List
关键字就地修改列表,例如它们更改目标变量的值。
它们也不返回任何内容-因此,在您使用它们的行上,您已将值None
分配给变量,从而导致错误。