USSD Steps¶
USSD commands can be used to send/receive certain information or change settings. For example, to check a subscriber's balance by sending an account enquiry. The available USSD codes depend on the phone, the network operator and whether it is a prepaid phone or not.
USSD Configuration ¶
USSD codes can be configured as Context Objects in a .conf
file.
Syntax
1 2 3 4 5 | ContextObjects { ... <name Identifier> = <ussdCode String> ... } |
Parameters
-
name - The name assigned to the USSD code
-
ussdCode - The USSD code
Example
1 2 3 4 5 6 | ContextObjects { ... ussdAccEnq = "*106#" LastTransactionCost = "*102#" ... } |
Sending a USSD Code ¶
Sends the USSD Code
Syntax
1 | <name Identifier> sends the following ussd <ussdCode String> |
Parameters
-
name - The name assigned to the USSD code
-
ussdCode - The USSD code
Example
1 | And A sends the following ussd ussdAccEnq |
This Step is eligible for:
-
Timed
-
Deferred
Receiving a USSD Response ¶
Checks if a response to the USSD code has arrived. The response will be saved as a variable.
Syntax
1 | within <time Number> seconds, <name Identifier> receives an ussd response as <ussdName Identifier> |
Parameters
-
time - A number referring to the amount of time in seconds
-
name - The name assigned to the phone receiving the USSD response
-
ussdName - The name assigned to the USSD response
Example
1 | And within 30 seconds, A receives an ussd response as RESP1 |
This Step is eligible for
- Deferred
Responding to a USSD ¶
Creates a response to a received USSD code. For example, if the USSD code sent has accessed a menu. Use the following Step to navigate through the menu.
Syntax
1 | <name Identifier> responds to interactive ussd with <response String> |
Parameters
-
name - The name assigned to the phone responding to the USSD
-
response - The response sent by the phone
- This string will always be numeric
Confirming the correct response to a USSD may require manually navigating through a menu.
Example
1 | And A responds to interactive ussd with "2" |
This Step is eligible for:
-
Timed
-
Deferred
Canceling a USSD Dialog ¶
Exits a USSD menu.
Syntax
1 | <name Identifier> cancels interactive ussd dialog |
Parameter
- name - The name assigned to the phone canceling the USSD dialog
Example
1 | And A cancels interactive ussd dialog |
This Step is eligible for:
-
Timed
-
Deferred
Using a Data Extractor for USSD ¶
intaQt's Extractor can be used to filter or extract data from a USSD response.
Syntax
1 | extract <variable1 String> with <extractor Identifier> from <variable2 String> |
Parameters
-
variable1 - The variable that stores the data from
variable2
-
extractor - The name assigned to the extractor
-
variable2 - The content of the USSD response
Example
1 | And extract data1 with ussdFirstAccEnq from RESP1.text |
In the example above, data1
holds the amount received after the extraction from RESP1
.
Test Case Example: Sending and Receiving USSD¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | Feature: USSD Scenario Outline: USSD Given an Android phone as A And an Android phone as B And A sends the following ussd "*100#" And within 20 seconds, A receives an ussd response as RESP1 And extract data1 with ussdFirstAccEnq from RESP1.text When A dials the number B.number And within 50 seconds, B detects an incoming call from A.number And after 2 seconds, B answers the incoming call And within 5 seconds, A connects And after <dur> seconds, A ends the call and, within 10 seconds, he and B disconnect And A sends the following ussd "*100#" And within 20 seconds, A receives an ussd response as RESP2 And extract data2 with ussdFirstAccEnq from RESP2.text Then the charge for <charge>(<dur>) is (data1.bal - data2.bal) Examples: | dur | charge | | 5 | VoiceCharge | | 10 | VoiceNational | |