1

I have the following code:

*** Test Cases ***
Testing Connect to SQL Server
       ${queryTest}   Execute Sql String     SELECT * FROM users where Id='1'
       #log to console   ${queryTest}   //This print NONE
       #${query_results}   SeleniumLibrary.Get Text  ${queryTest}
       #log to console   ${query_results} 
       #${value}=    Set Variable    ${queryTest[0][0]}
       log to console   ${value} 
       log to console   should display result 
       ${rowCount}=     Row Count   SELECT * FROM users where Id='1'
       log to console   ${rowCount}  
       #rowCount print 1

What I'm trying to do is printing the query's result in the console

4
  • What's the outcome of your script? What does it print into console? What errors do you get if any? Commented Jan 4, 2021 at 11:08
  • log to console ${queryTest} //This print NONE,, ${output} = Set Variable ${queryTest[1]} log to console ${output} >> This print the following error: Resolving variable '${queryTest[1]}' failed: IndexError: list index out of range,,, and in the report file it shows "@{queryTest} = [ ]" Commented Jan 4, 2021 at 11:12
  • Is your DB connection created successfully? I don't see any Connect To Database keyword in the script, it might be elsewhere, but it might be wrong, unsuccessful etc. Commented Jan 4, 2021 at 11:16
  • the connection is created successfully as I've printed row count as you see in the code ${rowCount}= Row Count SELECT * FROM users log to console ${rowCount} Commented Jan 4, 2021 at 11:18

1 Answer 1

3

I think Execute Sql String doesn't return anything. There's no return statement in the method, and documentation doesn't mention such an example either (even though they mention a select statement with this keyword, which might be what leads people to believe they eventually get some rows back).

Try using Query keyword:

@{queryTest}    Query    SELECT * FROM users where Id='1'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.