-
Notifications
You must be signed in to change notification settings - Fork 16
Dynamic variable declaration
Dynamic variable lets user define variable that can replaced at run time from test data excel sheet, system properties or from environment variable. The purpose of having this feature helps users to write tests that can run parallely with different test inputs and to write test steps that refer inputs from previous test step run.
example:
Step | Target | Action | Input | Overrides |
---|---|---|---|---|
navigate to page | goto | {{app}} |
Let say you have above example excel test that has a step to navigate to a page. you can directly put a url under input column where it says '{{app}}', But that means your test step is bound to that url which doesn't give you much flexiablity to change the url easily without manually open the excel sheet and change it to a different url value. Dynamic variable reference helps you to easily change any input value from different input sources. Below section explains how many test data input source that the framework is reading from and there priority heirarchy.
There can be different source where you can define key -> value pair to be used in your test. List of source you can have test data references:
- System properties
- Environment variable
- d-dataSheet excel sheet (default test data sheet)
- d- excel sheet
Test data values defined in system properties take a higher priority. example:
-Dapp=https:\\www.yahoo.com
Above we are overriding the input value of "{{app}}". If you already cloned codeless project on your local, go to <INSTALL_ROOT>/example_usage/bin folder path. There you can find windows and mac shell script files that executes codeless jar project. Open one of the files then you will find a line that excutes codeless jar. There you can add a system properties as showen below.
java "-Dapp=https:\\www.yahoo.com" -jar codeless_test-0.0.3-SNAPSHOT-jar-with-dependencies.jar -suite="%1"
If you open command prompt on windows and run command 'Set', you will see list of environment variables defined. If you have to use any environment variable definition on you test data sheet that will be possible. Environment variables take the second priority below System properties.
Supported sheet Name = "d-dataSheet" Data sheet defines key value pair that can be used to substitute any dynamic value definitions ({{key}}). If variable key defined in test sheet doesn't match any of system properties or environment variable it looks value from this sheet. example: Below is the test case sheet,
Step | Action | Target | Input | Overrides |
---|---|---|---|---|
search google ui | goto | {{google}} | ||
sending search key | sendKeys | {{search}} | {{key}} |
For above test sheet the respective Data sheet will be, example:
Key | Value |
---|---|
https://www.google.com/ | |
search | Google.googlepage.searchbar |
Key | seattle |
Each curly brace variable definitions can be refer from above test data sheet definitions.
Supported sheet Name = "d-dev" This sheet takes lower priority than System properties, environment variable and default data sheet.
example:
Key | Value |
---|---|
https://www.google.com/ |