2017-05-05 91 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