Skip to main content

File actions

I attach "<filepath>" as "<name>"

or since v3.0.0

I attach "<filepath>" as <name>

Attaches a local file to the Gwen report and assigns it a name. The link to the attachment in the report will have the given name.

Where

  • <filepath> the path to the local file to attach
  • <name> the name to assign to the file attachment

Example

   When I attach "path/to/data.csv" as "data"

Or since v3.0.0

   When I attach "path/to/data.csv" as data
I attach "<filepath>"

Attaches a local file to the Gwen report and assigns it the same name as the file.

Where

  • <filepath> the path to the local file to attach

Example

   When I attach "path/to/data.csv"
I <write|append> "<text>" to "<filepath>" file

Writes or appends text to a file.

Where

  • <write|append> is one of:

    • <write> to overwrite entire content of file with the provided text
    • <append> to append the provided text to existing content in file
  • <text> the text to write or append to the file
  • <filepath> the path to the local file to write or append the text to

Example

   When I write "automation" to "path/to/file.txt" file
I <write|append> <textRef> to "<filepath>" file

Writes or appends a text reference value to a file.

Where

  • <write|append> is one of:

    • <write> to overwrite entire content of file with the provided text
    • <append> to append the provided text to existing content in file
  • <textRef> is the name of the binding containing the text to write or append to the file

    • Can be the name of any binding that contains or resolves to a text value, including a web element in which case the text in the element will be dynamically retrieved and used.
  • <filepath> the path to the local file to write or append the text to

Example

   Given my content is
"""
Automation and robotics
for Gherkin
"""
When I write my content to "path/to/file.txt" file
I <write|append> new line to "<filepath>" file

Writes or appends a new line to a file.

Where

  • <write|append> is one of:

    • <write> to overwrite entire content of file with a new line
    • <append> to append a new line to existing content in file
  • <filepath> the path to the local file to write or append the new line to

Example

   When I append new line to "path/to/file.txt" file
I <write|append> "<text>" to <filepathRef file>

Writes or appends text to a referenced file.

Where

  • <write|append> is one of:

    • <write> to overwrite entire content of file with the provided text
    • <append> to append the provided text to existing content in file
  • <text> the text to write or append to the file
  • <filepathRef file> is the name of the binding containing the path of the file to write or append the provided text to

Example

   Given my file is "path/to/file.txt"
When I append "automation" to my file
I <write|append> <textRef> to <filepathRef file>

Writes or appends a text reference value to a referenced file.

Where

  • <write|append> is one of:

    • <write> to overwrite entire content of file with the provided text
    • <append> to append the provided text to existing content in file
  • <textRef> is the name of the binding containing the text to write or append to the file

    • Can be the name of any binding that contains or resolves to a text value, including a web element in which case the text in the element will be dynamically retrieved and used.
  • <filepathRef file> is the name of the binding containing the path of the file to write or append the provided text to

Example

   Given my file is "path/to/file.txt"
And my content is
"""
Automation and robotics
for Gherkin
"""
When I write my content to my file
I <write|append> new line to <filepathRef file>

Writes or appends a new line to a referenced file.

Where

  • <write|append> is one of:

    • <write> to overwrite entire content of file with a new line
    • <append> to append a new line to existing content in file
  • <filepathRef file> is the name of the binding containing the path of the file to write or append the new line to

Example

   Given my file is "path/to/file.txt"
When I append new line to my file
I log record to <resultsFileId> file

Logs a record to the results file having the given ID (if results is specifed in the format launch option only).

Where

  • <resultsFileId> the ID of the results file to log a record to

Example

   When I log record to my.results file