Nexial Automation

Test Automation Platform for everyone!

X

io » writeFileAs(file,content,append)

Description

Like writeFile(file,content,append), this command writes content to file, with an optional flag to append to existing content. However, this command will not exercise any data variable substitution during the file-write operation. This means that if content contains any ${...} text, such text will be left as is. The writeFile(file,content,append), on the other hand, will perform data variable substitution during its file-write operation.

The content parameter may be a fully qualified file path or text content. Nexial will resolve this variation internally. Use the append parameter to either overwrite (if file exists) or append content.

In general, it would be a good idea to derive at a predictable outcome inasmuch as reasonable. However the end-of-line (EOL) character (a.k.a. newline or nextline) is system-dependent. On Windows, it’s usually a combination of carriage return (\r) and line feed (\n). On *NIX/Mac it’s usually just the line feed (\n). One can usually generalize this using the (eol) syntax and let Nexial figures out the appropriate character(s) to use.

In order to compensate for the differences, Nexial supports a few different ways to handle the EOL characters. Using the nexial.io.eolConfig System variable, one can control the EOL characters to use:

  • as is: leave the EOL characters as is; whatever the content in question has is what will be used
  • platform: change the EOL characters according to the system currently running the automation. This is the default behavior.
  • windows: change the EOL characters to \r\n.
  • unix: change the EOL characters to \n.

For example, perhaps one is producing a file to be consumed by a UNIX process. It may be important to ensure that the EOL characters is set to unix. One can define the nexial.io.eolConfig System variable to unix - either via the data file or via base » save(var,value) command.

Parameters

  • file - this parameter if the full path of the file along with file name to which the content has to be written.
  • content - this parameter is the content which need to written to the file
  • append - this parameter is a boolean value if you want to append the existing value or ignore it.

Example

See Also