我想知道如何将该值转换为ArrayList?
${doc1}= Open Excel Document filename=${OpenExcel} doc_id=doc1
${view_bicccicmdu}= Read Excel Row row_num=1 max_num=6 sheet_name=UpperTT
${view_bicccicmduCheckLength}= Get Length ${view_bicccicmdu}
${HG}= Get Text ${ClickAV.CheckColumn}
${HGLenght}= Get Line Count ${HG}
Should Be Equal ${HGLenght} ${view_bicccicmduCheckLength}
Should Contain ${HG} ${view_bicccicmdu} ignore_case=True
Close Excel Document
但是结果是
${HG} = Nodename
Transdate
BICC Support FAX Detection
Trunk Group Number
Bill Trunk Group Number
MGW Name Trunk
Group Name
Sub-Route Name
Circuit Type
Group Direction
Circuit Selection Mode
我需要将其转换为ArrayList并应计为11条记录,我该怎么办?
答案 0 :(得分:1)
您可以使用字符串库,并使用\n
作为分隔符来分隔字符串,因为在这种情况下,数据由换行符分隔,因此可以将字符串分隔为列表。
使用分隔符作为分隔符字符串分割字符串。
如果未指定分隔符,则任何空格字符串均为分隔符。在 这种情况下,也可能会出现连续的空格以及前导和 尾随空格将被忽略。
分割的单词作为列表返回。如果可选的max_split为 给定,最多完成max_split个分割,返回的列表将 最大max_split +1个元素
您可以执行以下操作。
*** Test Cases ***
Test
${HG} = Set Variable Nodename\n ransdate\n ICC Support FAX Detection\n Trunk Group Number\n Bill Trunk Group Number\n MGW Name Trunk\n Group Name\n Sub-Route Name\n Circuit Type\n Group Direction\n Circuit Selection Mode\n
@{words} = Split String ${HG} \n
${HGLenght}= Get length ${words}
log ${words}
结果
${HGLenght} = 11
${words} = ['Nodename', 'ransdate', 'ICC Support FAX Detection', 'Trunk Group Number', 'Bill Trunk Group Number', 'MGW Name Trunk', 'Group Name', 'Sub-Route Name', 'Circuit Type', 'Group Direction', 'Circuit Selection Mode']
希望有帮助
答案 1 :(得分:-1)
再次感谢您,@ WojTek T 我的最终代码是
`${HG}= Get Text ${ClickAV.CheckColumn}
@{words} = Split String ${HG} \n
${UPPER1}= Evaluate "${words}".upper()
${UPPER2}= Evaluate "${view_dnc}".upper()
${HGLenght}= Get Line Count ${HG}
Should Be Equal ${HGLenght} ${view_dncCheckLength}
Should Contain ${UPPER1} ${UPPER2}`
我尝试使用具有表名的“获取列表项”,但是它不起作用,对于我问你的最后一个问题,我应该使用此解决方案。哈哈
再次感谢您。