Browser Automation Studio (BAS) Documentation

repository·master·Indexed 20 days ago

https://github.com/bablosoft/bas

A visual automation platform for creating standalone browser-based bots and applications. BAS features a low-code/no-code interface with 100% Chrome emulation, fingerprint switching, multithreading, and a high-speed HTTP client. It supports JavaScript and C++ extensibility, coordinate-based and element-based automation commands, and the ability to compile projects into standalone executables.

Tokens
2.7K
Snippets
8
Records
15
Agent score
69%

What's inside Browser Automation Studio

  1. Overview of Browser Automation Studio (BAS)

    master

    Browser Automation Studio (BAS) is a low-code/no-code solution for creating automation applications such as posters, spammers, parsers, uploaders, and social network apps. It functions like a macro recorder where user actions are recorded and can be edited or played back.

    Key capabilities include:

    • Browser Emulation: 100% Chrome emulation with fingerprint switching to emulate other browsers, WebRTC IP tracking disabling, and timezone changes.
    • Automation Logic: Drag-and-drop actions, conditions, loops, and a visual expression editor for generating JavaScript expressions.
    • Networking: Support for SOCKS and HTTP proxies, and a high-speed HTTP client capable of up to 2000 threads.
    • Extensibility: Supports arbitrary JavaScript execution and an extendable module system (written in JavaScript or C++).
    • Standalone Deployment: Projects compiled with BAS are standalone executables that do not require BAS or any other software to be installed on the target machine.
  2. Compile BAS and Custom Modules

    master

    If you need to change the BAS source code or compile your own modifications, refer to the official compilation instructions in the BAS Wiki.

    https://wiki.bablosoft.com/doku.php?id=how_can_i_change_bas_and_compile
  3. Configure Single Instance behavior with SingleApplication

    master

    The application uses SingleApplication to prevent multiple instances from running simultaneously.

    • By default, if an instance is already running, a QMessageBox will prompt the user to decide whether to start another instance.
    • To bypass this check and allow multiple instances, include the --notasksingleinstance flag in the command-line arguments.
    SingleApplication a(argc, argv, "BAS_UNIQUE_KEY");
    if(a.alreadyExists() && !a.arguments().contains("--notasksingleinstance"))
    {
        // Prompt user to start another instance...
    }
  4. Configure browser settings and lifecycle via Command Line

    master

    The ChromeWorker entry point (WinMain) parses command line arguments to initialize the automation environment.

    Argument Structure:

    • Arguments[1]: Language code (used by Translate::SetLanguage).
    • Arguments[2]: A unique Key used to establish communication via PipesClient.
    • Arguments[4] (Optional): The Process ID (Pid) of the parent process. If provided, a thread is spawned to monitor this PID via check_pid.

    Recording Mode: If the command line contains exactly 6 arguments, the worker enters IsRecord mode. In this mode:

    • Logging severity is set to LOGSEVERITY_VERBOSE.
    • The UI renders a state indicator (Ready, Hold, or Finished).
    • The browser rendering is handled differently to allow for recording/highlighting overlays.
  5. Initialize the MongoDB Database Connector

    master

    Before starting the main application loop, you must initialize the MongoDatabaseConnector. If initialization fails, the application will exit with code 2.

    if(!MongoDatabaseConnector::Init())
    {
        qDebug() << "Failed to init database";
        return 2;
    }
  6. Start the remote execution engine with Remote::Start

    master

    The Remote class serves as the entrypoint for the remote execution engine. To initialize the automation engine and begin processing arguments, call the Start method, passing the command-line arguments from the application. If Start returns true, the application should proceed to its standard event loop execution using a.exec().

    Remote u;
    if(u.Start(a.arguments()))
        return a.exec();
    else
        return 0;
  7. Execute element-based automation commands

    master

    The ChromeWorker supports a wide range of automation commands that can be executed on web elements. These commands are categorized into standard element functions and loop functions (which iterate over elements).

    Standard Element Functions:

    • ClickElement: Clicks an element.
    • MoveElement: Moves the cursor to an element.
    • DragElement: Drags an element.
    • DropElement: Drops an element.
    • MoveAndClickElement: Moves to and clicks an element.
    • Clear: Clears an input field.
    • Type: Types text into an element.
    • Exists: Checks if an element exists.
    • Style: Retrieves or sets element styles.
    • Check: Checks/unchecks a checkbox or radio button.
    • Screenshot: Takes a screenshot of an element.
    • GetCoordinates: Retrieves element coordinates.
    • Focus: Sets focus on an element.
    • Set: Sets a value.
    • SetInteger: Sets an integer value.
    • SetRandom: Sets a random value.
    • GetAttr: Gets an attribute.
    • SetAttr: Sets an attribute.
    • Captcha: Handles captcha elements.
    • Wait: Waits for an element.
    • Length: Gets the length of an element's content.
    • LoopElement: Loops through elements.

    Element Loop Functions: These functions are used when iterating over a collection of elements (e.g., via IDXmlLoop, IDTextLoop, or IDScriptLoop):

    • GetXml: Retrieves XML representation.
    • GetText: Retrieves text content.
    • ExecuteScript: Executes a script on the element.
    • ClickElement (Loop version)
    • MoveElement (Loop version)
    • MoveAndClickElement (Loop version)
    • Clear (Loop version)
    • Type (Loop version)
    • Exists (Loop version)
    • Style (Loop version)
    • Check (Loop version)
    • Focus (Loop version)
    • Set (Loop version)
    • SetInteger (Loop version)
    • SetRandom (Loop version)
    • GetAttr (Loop version)
    • SetAttr (Loop version)
    • Captcha (Loop version)
    • Screenshot (Loop version)
    • GetCoordinates (Loop version)
  8. Configure OpenSSL locking callbacks

    master

    To ensure thread safety with OpenSSL, the application sets custom locking and ID callbacks using CRYPTO_set_locking_callback and CRYPTO_set_id_callback. These callbacks use a custom MyOpenSslLocks implementation to manage QMutex instances for OpenSSL's internal locking requirements.

    CRYPTO_set_locking_callback(my_locking_function);
    CRYPTO_set_id_callback(my_id_function);
    
    // ... application execution ...
    
    CRYPTO_set_locking_callback(0);
    CRYPTO_set_id_callback(0);
  9. Manage Browser Tabs and Popups

    master

    The system manages multiple tabs and popups using specific command IDs. These are handled via the IDCustomPopups range.

    • Add New Tab: app->AddTab() (triggered by IDCustomPopups)
    • Select Tab: app->SelectTab(index) (triggered by IDCustomPopups + 1)
    • Close Tab: app->CloseTab(index) (triggered by IDCustomPopups + 2)

    Note: The index logic for closing/selecting is derived from the command ID offset.