Snooz82/robotframework-datadriver

Read literal "null" string from excel file

Closed this issue · 4 comments

Hi I was using Datadriver with xlsx files to run my tests and I met an issue.

So I have this ${var} defined in excel file and I want to pass a literal "null" string to it in one of my test cases.

However, when I set the ${var} value as null or 'null in excel, what is really passed to my test case is ${var}=' ', a blank space.

Please tell me how can I pass a literal from excel to my var.

Thank you!

You can try this:

https://github.com/Snooz82/robotframework-datadriver#ms-excel-and-typed-cells

I tried both preserve_xls_types=False and preserve_xls_types=True. Still get the same results.

It seems that this is a behaviour of pandas which is used to read that excel files.

pd.read_excel(file_path, sheet_name=sheet_name, dtype=object, engine="openpyxl").replace(nan, "", regex=True)

pandas reads the strings "nan" and "null" as nan which is basically None and has to be replaced by "" (empty string) because Excel same happens on empty cells.
I can not change anything about that.

You should be able to work around that by using Robot Frameworks python literal syntax.
${{"null"}} in that cell. it will be read as is, but evaluated by robot to the string "null"

Hope that helps you.

Indeed, Robot Frameworks python literal syntax solved my problem.
Thank you <333.