This script command waits until the requested external value is received or a specified timeout is reached.
If the external event is received, then the callback function provided shall be invoked and the value passed as its single parameter will hold the external value itself.
The external value is injected by invoking the REST API testruns/externalValue.
Arguments
Name | Type | Description |
---|---|---|
key | string | The external key to wait for |
callback | string | The function that will be called when the external value of the given key has been received |
time | string | The maximum number of milliseconds to wait. If this time passes, the test will fail |
Code example
client
.rtcWaitForExternalValue('email2fa', (value) => {
client.rtcInfo('Received 2fa value [${value}]');
}, 60000);
The example above waits to receive an external value with the key email2fa and then prints out its value to the log. If the key isn’t received within 60 seconds, the test will fail.
Notes
- This method is useful in handling external inputs that are required for your test script to run successfully, such as the ability to parse an email or an SMS message for a 2FA value
- testRTC supports other synchronization mechanisms