How To Read Values From Text File In Robot Framework

To Read Values From Text File In Robot Framework you can use the keyword “Get File” in Operating System  Library to read values from a text file. Let’s say, you have a text file “doc.txt” in your robot project folder . Bellow is the code how to read file form the text file.

The Code

*** Settings ***
Library OperatingSystem

*** Test Cases ***
Read Text File
 [Tags] test text
 ${TextFileContent}= Get File doc.txt
 Log ${TextFileContent}

After Execution of the above program the out put will be generated by robot framework.
The output is as follow

Starting test: File.Read Text File
20170922 11:53:47.470 : INFO : Getting file ‘<a href=”file://C:\Users\Maa\robot\doc.txt”>C:\Users\Maa\robot\doc.txt</a>’.
20170922 11:53:47.486 : INFO :
${TextFileContent} = *** Settings ***
Library Selenium2Library

*** Test Cases ***
Tc1
Open Browser http://www.google.com ff

20170922 11:53:47.486 : INFO :
*** Settings ***
Library Selenium2Library

*** Test Cases ***
Tc1
Open Browser http://www.google.com ff

Ending test: File.Read Text File

If you have nay doubt or error you can give your feed back on How To Read Values From Text File In Robot Framework

 

 

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *