question

maiphan avatar image
maiphan asked maiphan posted

How to use iTest command write and readfile

- I would like to use write to write a table and save but I'm not successful.

 

- I use command readfile but it always go to the workspace director even when I use absolute path, such as: C:\test.txt. So how I can pass the absolute path in readfile command?

 

Thank you.

 

 

iTest
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
PaulD avatar image
PaulD answered PaulD posted

When you say "write", I assume you mean "writeFile".  "write" is used for populating the response to the current procedure call.  "writeFile" creates or appends content to a file.

 

When you use a path, you should be careful about using backslashes -- because these will be substituted by default.  Safer to use forward slashes.  For example,

 

writeFile                 c:/test.txt  $value

 

If you really want to use backslashes, you need to escape them:

 

writeFile                 c:\\test.txt   $value

 

 

2 comments
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

KumarS avatar image KumarS commented ·

In order to be good citizen with iTest, recommended way would be to use the URI instead of direct paths. So you should use:

 

writeFile file://c:/test.txt $value

 

This will provide you with best forward compatibility as you upgrade to newer versions of iTest.

0 Likes 0 ·
PaulD avatar image PaulD KumarS commented ·

I believe the correct URI format is

 

file:/c:/test.txt

 

(One slash after the scheme rather than two.)  Two slashes are used when the next segment is a server.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.