0

I created a text file that has 1 value in it by using Create File keyword

${getDateLetter} =    getValue        name=date
createFile              Resources\\Client\\DateLetter.txt      ${getDateLetter}

In other script, I'm trying to read the value in text file using Get File keyword

Library     OperatingSystem

${dateLetter} =     getFile     Resources\\Client\\DateLetter.txt

But it will throw this error

Cell in table 'css=#tbl-letter' in row #2 and column #2 should have contained text 'getFile Resources\Client\DateLetter.txt'.

Ahmad Saifullah
  • 9
  • 1
  • 1
  • 2
  • What line gives this error? I tried to reproduce your problem but your code creates a file and later reads it nicely. – Pekka Apr 15 '16 at 06:52
  • ${dateLetter} = getFile Resources\\Client\\DateLetter.txt. This code will throw an error. If i use keyword get file and create file within 1 script, there will be no problem. But i dont know why if i seperate these 2 keyword, it will throw an error. Am I missing something? – Ahmad Saifullah Apr 15 '16 at 07:53
  • You are missing something but I cannot tell what. Get File keyword should not give error message you got. I would start by removing all extra code around getfile and seeing if it still fails. When it works,bring back more code until you find what causes your problem. Start by having only those two lines in your second test file to be sure it reads properly. – Pekka Apr 15 '16 at 10:48
  • `Get File` is not returning an error, some other keyword is returning an error. It looks like you're trying to run a keyword that accepts text (such as "Should be equal", and you're trying to give it the `Get File` keyword instead. – Bryan Oakley Apr 18 '16 at 21:37

1 Answers1

1
*** Settings ***
Library           OperatingSystem

*** Test Cases ***
Test 1
    Keyword 1
    Keyword 2

*** Keywords ***
Keyword 1
    Create File    C:/temp/robot_test/test1.txt    Hello World...!!!    encoding=UTF-8

Keyword 2
    ${Test}    Get File    C:/temp/robot_test/test1.txt    encoding=UTF-8    encoding_errors=strict

This works for me, Can you specify what data you are writing into file.

dilip s
  • 11
  • 2