修改Robot Framework中的列表列表
我有一个在机器人框架中使用的嵌套列表。我想更改机器人框架级别的子列表中的一项。
我的列表如下所示:
[ bob, mary, [june, july, august]]
我想将“july”更改为其他内容,例如“september”,
Robot Framework 将允许我更改“bob”或“mary”,但是如果我尝试插入一个列表,它被转换为字符串。
(哦,我尝试过使用“Insert Into List 关键字来插入新的子列表,以及其他 List 关键字,但没有任何运气。)
I have a nested list that I am using in Robot Framework. I would like to change one item in a sublist at the Robot Framework level.
My list looks like this:
[ bob, mary, [june, july, august]]
I want to change "july" to something else, say "september"
Robot Framework will let me change 'bob' or 'mary', but if I try to insert a list, it is converted into strings.
(Oh, I have tried to use the "Insert Into List keyword to insert a new sub list, and other List keywords, no luck with any.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我能够使用集合库关键字实现修改,就像这样
我无法找到直接更改子列表的方法,必须首先提取它,然后修改,最后放回原位。
I was able to achieve the modification with Collections library keywords like this
I was not able to find a way to directly alter the sublist, it has to be first extracted, then modified and finally put back in place.
由于缺乏回应,我猜测对此没有一个简洁干净的解决方案。这是我所做的:
我因此创建了一个实用程序:
然后将此条目放入我的机器人框架测试套件文件中:(
当然,导入我的实用程序库)
运行后,子列表中的第二项(索引 1)位于列表的索引 1 将是“NewItem”
也许不是最优雅或最灵活的,但它现在可以完成工作
I am guessing from the lack of response that there isn't a neat clean solution to this. Here is what I have done:
I created a utility thusly:
I then put this entry in my robot framework test suite file:
(Importing my utility library, of course)
After this runs, the second item (index 1) in the sublist at index 1 of the list will be "NewItem"
Perhaps not the most elegant or flexible, but it will do the job for now
集合库中的普通方法“设置列表值”确实适用于嵌入列表 - 并且它就地更改,无需重新创建对象;这是概念验证:
The normal method "Set List Value" in the Collections library does work on the embedded list - and its changed inplace, w/o recreating the objects; here's the POC: