Removing Trailing Comma from Query result in Robot Framework

风格不统一 提交于 2019-12-08 12:54:38

问题


I am extracting data from MySQL that returns query results as follows:

    ${A} = (('HFL', 'TCFLORWWGMAFVFEQLVRN', 'ZZG', 1625, 'SA,WE,DN_IS,', 84))

In this part 'SA,WE,DN_IS,' the trailing Comma needs to be removed for data validation. I am using robot framework for this and created loops to extract data from the list and compare individual elements with data on the webpage. So far I did not find any method in Robot Framework, specially Collections Library that I can use to remove the trailing comma. Is there any way to remove it using Robot Framework? Thanks in advance for your help.


回答1:


You can remove the trailing comma or any trailing character in a string by using "Get Substring" keyword of String library.

Example code:

*** Settings ***
Library    String

*** Variables ***
${a}=    SA,WE,DN_IS,

*** Test Cases ***
Remove last character of a string
    log to console    ${a}
    ${b}=    Get Substring    ${a}    0    -1
    log to console    ${b}


来源:https://stackoverflow.com/questions/45602428/removing-trailing-comma-from-query-result-in-robot-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!