Runtime Entities

Static Variables

Static variables are variables that are set by the system in a certain context and typically contain values of certain environment parameters in this context. Static variables, like arguments, can be used only for reading, you can not set or change them. Also, static variables can not be used in data substitution, in contrast to variables and arguments.

Static variables created in a specific context are available in all valid contexts, and also are context-dependent.

The following static variables are currently available:

Variable Description Context
lastUrl URL of last loaded page All
url URL of current page Page, Block, Form
responseCode Current HTTP request server response code Page, Block, Form
filename Last saved file or image filename All
object_saved If object has been saved to the DB, this variable gets value "yes". If object has been skipped (when object is saved in update mode), value will be "no". All
pool_ignored Contains number of duplicate URLs that were ignored by the link_add command. All

Despite the fact that static variables are available in practically all contexts, you can use them only in a block context, because the register exists only in a block context and the only command for static variables works with the register.

Below is an example of using a static variable url:

          ---
config:
    agent: Chrome
do:
- walk:
    to: http://www.somesite.com
    do:
    - find:
        path: body
        do:
        - static_get: url
        - variable_set: page_url # now we have value http://www.somesite.com in the variable with name `page_url`