我需要将存储在全局变量中的值传递给变量的另一个值。
场景:
我正在使用SQL查询从数据库中获取值并将其存储在全局变量中。
现在,我需要检查获取的值是否满足 进一步测试所需的条件。所以为了做到这一点 需要将获取的值传递到第二个SQL查询中
下面是示例代码
*** Settings ***
Library Process
Library DatabaseLibrary
Library Selenium2Library
*** Variables ***
${query} SQL statement to fetch value from a table
${query2} SQL statement to check condition whether the ${query1} fetch
value satisfies required conditions
***Test Cases***
LINES TO CONNECT TO Db
${DBQueryresult} Query ${query}
Log ${DBQueryresult}
Set Global Variable ${GlobalVariable} ${DBQueryresult[0][0]}
Query ${query2}
我需要在$ {query2} SQL语句中传递此$ {GlobalVariable}。
如何实现此目标或该解决方案还有其他方法
答案 0 :(得分:1)
不清楚您要尝试什么,但这也许会有所帮助。您可以使用$ {}
将vars嵌入查询字符串中*** Settings ***
Library Process
Library DatabaseLibrary
Library Selenium2Library
*** Variables ***
${query} SQL statement to fetch value from a table
${query_check} SQL statement to check condition whether the ${query} fetch
value satisfies required conditions
***Test Cases***
LINES TO CONNECT TO Db
${result} Query ${query}
Log ${result}
${check}= Query Check ${DBQueryresult[0][0]}
*** Keywords ***
Query Check ${result}
${other_result}= Query New_Query_with_${result}
[Return] ${other_result}