简体   繁体   中英

If i store index number fetched from db in variable & using in select from list by index, m getting err as expected string, int found-Robot Framework

enter image description here

select from list by index  ${locator_var}   ${inp_msge_type}

--getting error as expected string, int found

select from list by index  ${locator_var}   7

-----not getting any error

${inp_msge_type}----contains 7 from DB query the result is stored in this variable, to avoid hard coding we need to do this Is there any way to write

Do not add links to screenshots of code, or error messages, and format the code pieces accordingly - use the ` (tick) symbol to surround them.


The rant now behind us, your issue is that the keyword Select From List By Index expects the type of the index argument to be a string.

When you called it

Select From List By Index    ${locator_var}   7

, that "7" is actually a string (though it looks like a number), because this is what the framework defaults to on any typed text. And so it works.

When you get the value from the DB, it is of the type that the DB stores it with; and probably the table schema says it is int. So now you pass an int to the keyword - and it fails. The fix is simple - just cast (convert) the variable to a string type:

${inp_msge_type}=    Convert To String    ${inp_msge_type}

, and now you can call the keyword as you did before.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM