2017-05-05 92 views

回答

3

你也可以这样做。

${SUITE NAME.rsplit('.')[0]} 
5
${the name}= Set Variable ${SUITE NAME} 

# split the output on every . character 
${the name}= Split String ${the name}  separator=. 

# get the last member of the split 
${the name}= Set Variable @{the name}[-1] 

Log To Console  ${the name} # prints testsuitename in your example 

P.S.如果你在你的套件名称中使用点,它会变得讨厌。

+0

在第三步骤'@ {名称} [ - 1]'应'@ {名称[-1]}' –

+0

@OrsuSuni即没有这么。检查[访问单个列表项目](http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#list-variables),访问列表成员的格式就像我写的。 '@'操作数不会列出扩展,并且您将选择最后一个元素。调用'{name [-1]}'是[扩展变量语法](http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#extended-variable-syntax)的一部分,它会起作用如果var使用'$'调用,但是会按照您的建议使用'@'调用,因为... – Todor

+0

...成员不是类似列表的对象(它是一个字符串),因此无法展开。随时检查自己,这将无法正常工作:) – Todor