Skip to content
CheshireCaat edited this page Mar 9, 2020 · 10 revisions

You can send custom messages to your script using BasRemoteClient. It's very useful if you want to perform actions like:

  • Retrieve results/logs.
  • Set/get global variables.
  • Show/hide browsers. and other different actions.

You can send a custom message using the send_async method. This method can be used with the await keyword. In this case, the response will be contained in the variable you specify. You can also send message synchronously using asyncio event loop. If want to do this, you can use the event_loop.run_until_complete() function. You can read more about asyncio here.

Take a look at examples:

Send message and wait for result

# Set global variable with name 'TEST_VARIABLE' and value 'Hello'.
await client.send_async('set_global_variable', {
    'value': json.dumps('Hello'),
    'name': 'TEST_VARIABLE',
})

# Retrieve actual variable value.
actual = await client.send_async('get_global_variable', {
    'name': 'TEST_VARIABLE'
})

# Print the value.
print(actual)

Just send message

Among other options, you can just send a custom message. For example, if you want to show the database manager window, you can run the following code:

await client.send('show_database_manager');

After sending this message, you will see a manager window.

Main difference between send_async and send methods can be described by the following points:

  • The send_async method marks the outgoing message as asynchronous.
  • The send_async method sends message and waits for response.
  • The send method does not wait for the result.

The use of this methods depends on which message you want to send. You can learn more about it on the BAS official web interface documentation page.

Clone this wiki locally