Skip to content

Result Files

Go to Result Files

Using the BotCity Maestro SDK you can upload artifacts to the BotCity Maestro orchestrator to make it available to other users or applications via the web portal or via API.

Result Files

We call these files artifacts because they are the result of the execution of a task and can be any kind of file.

Tip

Explore the Snippet Generator to get code examples that facilitate result files manipulations, access and learn how to upload an artifact, list all artifacts and download an artifact via code.

The generated snippets are available in languages Python, Java, JavaScript, and TypeScript.

How to use result files with Maestro SDK

You can easily upload results files to the platform using the Maestro SDK in your automation code.

Installation

If you don't have the dependency installed yet, just follow these instructions:

pip install botcity-maestro-sdk

Important

In addition to installing, remember to include the dependency in the bot's requirements.txt file.

<repositories>
    <repository>
        <id>nexus-botcity-public</id>
        <url>https://devtools.botcity.dev:8081/repository/botcity-public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

<dependencies>
    <!-- Your other dependencies -->
    <dependency>
        <groupId>dev.botcity</groupId>
        <artifactId>maestro-sdk</artifactId>
        <version>2.0.3</version>
    </dependency>
</dependencies>
npm i @botcity/botcity-maestro-sdk
npm i @botcity/botcity-maestro-sdk

Importing the SDK

After installation, import the dependency and instantiate the Maestro SDK:

# Import for integration with BotCity Maestro SDK
from botcity.maestro import *

# Disable errors if we are not connected to Maestro
BotMaestroSDK.RAISE_NOT_CONNECTED = False

# Instantiating the Maestro SDK
maestro = BotMaestroSDK.from_sys_args()
# Fetching the details of the current task being executed
execution = maestro.get_execution()
// Import for integration with BotCity Maestro SDK
import dev.botcity.maestro_sdk.*;
...

public void action(BotExecution botExecution) {

    try {
        // Instantiating the Maestro SDK
        BotMaestroSDK maestro = new BotMaestroSDK();
        maestro.login(botExecution);
    ...
// Import for integration with BotCity Maestro SDK
const { BotMaestroSdk } = require('@botcity/botcity-maestro-sdk')

// Getting parameters passed by Runner
const args = process.argv.slice(2)
const [server, taskid, token] = args

// Login with information from the Dev. Environment page
const maestro = new BotMaestroSdk()
maestro.login("YOUR_SERVER_HERE", "YOUR_USER_HERE", "YOUR_KEY_HERE")

// Fetching the details of the current task being executed
const executionTask = await maestro.getTask(taskid)
// Import for integration with BotCity Maestro SDK
import { BotMaestroSdk } from '@botcity/botcity-maestro-sdk'

// Getting parameters passed by Runner
const args = process.argv.slice(2)
const [server, taskid, token] = args

// Login with information from the Dev. Environment page
const maestro: BotMaestroSdk = new BotMaestroSdk()
maestro.login("YOUR_SERVER_HERE", "YOUR_USER_HERE", "YOUR_KEY_HERE")

// Fetching the details of the current task being executed
const executionTask: Task = await maestro.getTask(taskid)

Uploading an result file

# Uploading a result file (artifact) to the Maestro.
maestro.post_artifact(
    task_id=execution.task_id,
    artifact_name="My Artifact.png",
    filepath="screenshot.png"
)
// Uploading a result file (artifact) to the Maestro.
File artifact = new File("screenshot.png");
maestro.postArtifact(botExecution.getTaskId(), "My Artifact.png", artifact);
// Uploading a result file (artifact) to the Maestro.
const filepath = "screenshot.png"
const artifact = await maestro.createArtifact(executionTask.id, "My Artifact.png", filepath)
// Uploading a result file (artifact) to the Maestro.
const filepath: string = "screenshot.png"
const artifact: Artifact = await maestro.createArtifact(executionTask.id, "My Artifact.png", filepath)

Complete code

from botcity.core import DesktopBot
from botcity.maestro import *

# Disable errors if we are not connected to Maestro
BotMaestroSDK.RAISE_NOT_CONNECTED = False

def main():
    maestro = BotMaestroSDK.from_sys_args()
    execution = maestro.get_execution()

    bot = DesktopBot()

    # Take and save a screenshot in the path given
    bot.save_screenshot("screenshot.png")

    # Uploading a result file (artifact) to the Maestro
    maestro.post_artifact(
        task_id=execution.task_id,
        artifact_name="My Artifact.png",
        filepath="screenshot.png"
    )

    # Implement here your logic...
    ...

def not_found(label):
    print(f"Element not found: {label}")

if __name__ == '__main__':
    main()
import dev.botcity.framework.bot.DesktopBot;
import dev.botcity.maestro_sdk.BotExecutor;
import dev.botcity.maestro_sdk.BotMaestroSDK;
import dev.botcity.maestro_sdk.model.AlertType;
import dev.botcity.maestro_sdk.runner.BotExecution;
import dev.botcity.maestro_sdk.runner.RunnableAgent;

public class FirstBot extends DesktopBot implements RunnableAgent
{
    public FirstBot() {
        try {
            setResourceClassLoader(this.getClass().getClassLoader());
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void action(BotExecution botExecution) {

        try {
            BotMaestroSDK maestro = new BotMaestroSDK();
            maestro.login(botExecution);

            // Take and save a screenshot in the path given
            saveScreenshot("screenshot.png");

            // Uploading a result file (artifact) to the Maestro.
            File artifact = new File("screenshot.png");
            maestro.postArtifact(botExecution.getTaskId(), "My Artifact.png", artifact);

            // Implement here your logic...
            ...

        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    private void notFound(String label) {
        System.out.println("Element not found: "+label);
    }

    public static void main(String[] args) {
        BotExecutor.run(new FirstBot(), args);
    }
}
const main = async () => {
    const { BotMaestroSdk } = require('@botcity/botcity-maestro-sdk')

    const args = process.argv.slice(2)
    const [server, taskid, token] = args

    const maestro = new BotMaestroSdk()
    maestro.login("YOUR_SERVER_HERE", "YOUR_USER_HERE", "YOUR_KEY_HERE")

    const executionTask = await maestro.getTask(taskid)

    const desktopBot = new DesktopBot()

    // Take and save a screenshot in the path given
    const filepath = await desktopBot.screenshot('/home/user/', 'screenshot.png')

    // Uploading a result file (artifact) to the Maestro.
    const artifact = await maestro.createArtifact(executionTask.id, "My Artifact.png", filepath)

main()
const main = async () => {
    import { BotMaestroSdk } from '@botcity/botcity-maestro-sdk'

    const args = process.argv.slice(2)
    const [server, taskid, token] = args

    const maestro: BotMaestroSdk = new BotMaestroSdk()
    maestro.login("YOUR_SERVER_HERE", "YOUR_USER_HERE", "YOUR_KEY_HERE")

    const executionTask: Task = await maestro.getTask(taskid)

    const desktopBot = new DesktopBot()

    // Take and save a screenshot in the path given
    const filepath = await desktopBot.screenshot('/home/user/', 'screenshot.png')

    // Uploading a result file (artifact) to the Maestro.
    const artifact: Artifact = await maestro.createArtifact(executionTask.id, "My Artifact.png", filepath)

main()

Tip

Look at the other operations we can do with result files using the BotCity Maestro SDK and BotCity Maestro API.