Skip to content
Advertisement

Error when executing a test whose .sql file has variable (Robot Framework)

I have the following situation, could you help me?

I would like to leave some dynamic data (variables) inside my .sql file and execute my test correctly in .robot file.

However, when I go to do my test, it returns an error, that is, the variable is not mounted correctly. I think I’m leaving something “behind”.

Could anyone help me?

.sql file below (I want my variable name):

INSERT INTO TBMENSAGEMITEM (NUM_MESSAGE, SEQUENCE)
VALUES (@NUMERO_MENSAGEM, ${NAMES})

.robot file below:

*** Variables ***
${NAMES}                          'JOAO'

*** Test Cases ***
Test Variable

${file}   Get File             ${EXECDIR}/spb/scripts/SQL/fileTest.sql
${NAMES}   Replace Variables    ${file}

  Execute Sql Script    ${NAMES}

Error below:

OSError: [Errno 22] Invalid argument:

I’m sure I’m wrong in my .robot file. But I don’t know where.

Could anyone help?

Thank you very much in advance!

Advertisement

Answer

OSError indicates that the issue is running some command on Operating system level.

Execute sql script keyword – if it it’s from databaselibrary (your code snippet doesn’t show settings section) takes a name of a file as parameter.

Replace variables parameter takes a string and returns a string.

Then you pass a string as a parameter to keyword that takes a filename. Which leads to a OSError since string is not same as file.

Once you have used the replace variables, you should write that string to a file or check if database library has a keyword to run a script from a string, not from file.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement