0.0
No release in over 3 years
Provides connectivity to the isoFleet engine via Redis for distributed browser automation.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 2.0
~> 10.0
~> 3.0

Runtime

>= 2.7
>= 4.0
 Project Readme

isoAutomate Ruby SDK

The Sovereign Browser Infrastructure & Orchestration Platform

Gem version License Documentation ReadTheDocs

isoAutomate Architecture

Installation

Add this line to your application's Gemfile:

gem 'isoautomate'

And then execute:

bundle install

Or install it yourself as:

gem install isoautomate

Configuration

The SDK requires a connection to a Redis instance to communicate with the browser engine. You can configure this either via an environment file (.env) or directly in your Ruby code.

Method A: Environment Variables (.env) Create a .env file in your project root. This is the recommended way to keep credentials out of your source code.

# Individual Fields
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=yourpassword
REDIS_DB=0
REDIS_SSL=false

# OR Single Redis URL (overrides individual fields if present)
# REDIS_URL=rediss://:password@host:port/0

Method B: Direct Initialization

You can pass connection details directly when creating the Client instance.

require 'isoautomate'

client = Isoautomate::Client.new(
  redis_host: "localhost",
  redis_port: 6379,
  redis_password: "yourpassword",
  redis_db: 0,
  redis_ssl: true
)

# Or using a URL string
# client = Isoautomate::Client.new(redis_url: "rediss://:password@host:port/0")

Usage Examples

Browser sessions are managed through the Isoautomate::Client. To ensure that browser resources are cleaned up properly on the server, we highly recommend using a begin...ensure block.

1. Standard Pattern (Recommended)

Using ensure guarantees that the browser is released back to the fleet, even if your script crashes or an error occurs.

require 'isoautomate'

client = Isoautomate::Client.new

begin
  # 1. Acquire the browser instance
  # Returns a hash with session details
  session = client.acquire(browser_type: "chrome_profiled", video: true)
  puts "Connected to Worker: #{session['worker']}"
  
  # 2. Perform Actions
  client.open_url("[https://example.com](https://example.com)")
  client.assert_text("Example Domain")

  # Video URL is available via accessor or session hash
  puts "Session video: #{client.video_url}"

ensure
  # 3. CRITICAL: Always release resources
  client.release
end

The Acquire Method

The acquire method is used to claim a browser from your remote fleet. It supports several parameters to customize your environment.

Parameters

Parameter Type Default Description
browser_type String "chrome" The browser to use: chrome, brave, opera, or their _profiled variants.
video Boolean false When true, starts an MP4 recording of the browser session.
record Boolean false When true, records DOM events (RRWeb) for session replay.
profile String/Boolean nil Enables persistence for cookies, logins, and site data.

Understanding Persistence (Profiles)

Persistence allows you to resume sessions so you don't have to log in to websites repeatedly.

  • Managed Profile (profile: true): The SDK manages a persistent ID for you locally in a .iso_profiles folder.
  • Custom Profile (profile: "user_123"): You provide a specific string. Useful for managing specific accounts.
# Example: Using a named profile for a specific social media account
client.acquire(profile: "twitter_marketing_account")

Browser Actions

Once you have acquired a browser, you can control it using the following methods.

1. Navigation

Method Arguments Description
open_url(url) url Navigates the browser to the specified website.
reload(ignore_cache:, script:) ignore_cache: true, script: nil Force reloads. script runs JS immediately after load.
refresh - Reloads the current page (standard refresh).
go_back - Navigates to the previous page in history.
go_forward - Navigates to the next page in history.
internalize_links - Forces all links to open in the current tab instead of new ones.
get_navigation_history - Returns the list of URLs in the current session's history.

2. Mouse Interactions

Method Arguments Description
click(selector, timeout:) selector, timeout: nil Clicks an element. timeout waits for it to appear.
click_if_visible(selector) selector Attempts to click only if visible. Fails silently if not.
click_visible_elements(selector, limit:) selector, limit: 0 Clicks all visible instances. limit caps the count.
click_nth_element(selector, number:) selector, number: 1 Clicks the Nth element found in the DOM.
click_nth_visible_element(selector, number:) selector, number: 1 Clicks the Nth visible element.
click_link(text) text Finds a link by its visible text and clicks it.
click_active_element - Clicks the element that currently has focus.
mouse_click(selector) selector Simulates a mouse event click on the selector.
nested_click(parent, child) parent_selector, selector Finds parent first, then clicks child inside it.
click_with_offset(selector, x, y, center:) selector, x, y, center: false Clicks at coordinates relative to the element.
double_click(selector) selector Performs a double-click.
right_click(selector) selector Performs a context-menu (right) click.
hover(selector) selector Hovers the mouse over an element.
drag_and_drop(drag_sel, drop_sel) drag_selector, drop_selector Drags element 1 onto element 2.

3. Keyboard and Input

Method Arguments Description
type(selector, text, timeout:) selector, text, timeout: nil Rapidly enters text.
press_keys(selector, text) selector, text Simulates individual key presses (human-like).
send_keys(selector, text) selector, text Sends raw keys to element.
set_value(selector, text) selector, text Sets the value attribute directly via JS.
clear(selector) selector Deletes content of input/textarea.
clear_input(selector) selector Specific clear for <input> tags.
submit(selector) selector Submits the form containing the element.
focus(selector) selector Sets focus to the element.

4. GUI Actions (OS-Level Control)

Note: These require a _profiled browser engine (e.g., chrome_profiled).

Method Arguments Description
gui_click_element(selector, timeframe:) selector, timeframe: 0.25 Physically moves OS cursor to element and clicks.
gui_click_x_y(x, y, timeframe:) x, y, timeframe: 0.25 Physically clicks pixel coordinates.
gui_click_captcha - Auto-locates and physically clicks common captcha boxes.
solve_captcha - High-level trigger to handle captcha verification.
gui_drag_and_drop(drag, drop, timeframe:) drag, drop, timeframe: 0.35 Hardware-level drag and drop gesture.
gui_hover_element(selector) selector Physically hovers OS cursor over element.
gui_write(text) text Types text using OS virtual keyboard (bypasses DOM).
gui_press_keys(keys_list) keys_list (Array) Sends hardware keys (e.g. ['Control', 'c']).

5. Selects & Dropdowns

Method Arguments Description
select_option_by_text(selector, text) selector, text Selects option by visible text.
select_option_by_value(selector, value) selector, value Selects option by HTML value attribute.
select_option_by_index(selector, index) selector, index Selects option by list index (0-based).

6. Window & Tab Management

Method Arguments Description
open_new_tab(url) url Opens URL in a new tab.
open_new_window(url) url Opens URL in a new window.
switch_to_tab(index:) index: -1 Switches focus to tab index.
switch_to_window(index:) index: -1 Switches focus to window index.
close_active_tab - Closes current tab.
maximize - Maximizes window.
minimize - Minimizes window.
medimize - Resizes to medium standard size.
tile_windows - Arranges windows in a grid (Profiled only).
set_window_size(w, h) width, height Sets exact viewport dimensions.
set_window_rect(x, y, w, h) x, y, width, height Sets window position and size.

7. Data Extraction (Getters)

Method Arguments Description
get_text(selector:) selector: "body" Gets visible text of element.
get_title - Gets page title.
get_current_url - Gets current URL.
get_page_source - Gets raw HTML source string.
save_page_source(name:) name: "source.html" Saves HTML source to local file.
get_html(selector:) selector: nil Gets inner HTML of element.
get_attribute(selector, attribute) selector, attribute Gets value of specific attribute.
get_element_attributes(selector) selector Gets all attributes as a Hash.
get_user_agent - Gets User Agent string.
get_cookie_string - Gets cookies as a formatted string.
get_element_rect(selector) selector Gets element x, y, width, height.
get_window_rect - Gets window dimensions.
get_screen_rect - Gets screen resolution.
is_element_visible(selector) selector Returns true if visible.
is_text_visible(text) text Returns true if text exists on page.
is_checked(selector) selector Returns true if checkbox is checked.
is_selected(selector) selector Returns true if option is selected.
is_online - Returns connection status.

8. Cookies & Storage

Method Arguments Description
get_all_cookies - Returns array of all cookies.
add_cookie(cookie_dict) cookie_dict Injects a cookie (Hash).
delete_cookie(name) name Deletes specific cookie.
save_cookies(name:) name: "cookies.txt" Saves cookies to JSON file.
load_cookies(name:, cookies_list:) name, list Loads cookies from file or array.
clear_cookies - Clears all cookies.
get_local_storage_item(key) key Gets localStorage value.
set_local_storage_item(key, value) key, value Sets localStorage value.
get_session_storage_item(key) key Gets sessionStorage value.
set_session_storage_item(key, value) key, value Sets sessionStorage value.

9. Visuals & Highlights

Method Arguments Description
highlight(selector) selector Draws a border around element.
highlight_overlay(selector) selector Adds an overlay highlight.
remove_element(selector) selector Removes element from DOM.
flash(selector, duration:) selector, duration: 1 Flashes the element visibility.

10. Advanced (MFA, Permissions, Scripts)

Method Arguments Description
get_mfa_code(totp_key) totp_key Generates 2FA code from secret.
enter_mfa_code(selector, totp_key) selector, totp_key Generates and types 2FA code.
grant_permissions(permissions) permissions (Array) Grants permissions (e.g. clipboard).
execute_script(script) script Executes JS string.
evaluate(expression) expression Evaluates JS expression & returns value.

11. Assertions

All assertions take an optional screenshot: true (default). If the assertion fails, a screenshot is saved locally to screenshots/failures/.

Method Arguments Description
assert_text(text, selector:) text, selector: "html" Asserts text exists.
assert_exact_text(text, selector:) text, selector: "html" Asserts exact text match.
assert_element(selector) selector Asserts element exists.
assert_element_present(selector) selector Same as above.
assert_element_absent(selector) selector Asserts element does NOT exist.
assert_element_not_visible(selector) selector Asserts element is hidden.
assert_text_not_visible(text, selector:) text, selector Asserts text is hidden.
assert_title(title) title Asserts page title.
assert_url(url_substring) url Asserts URL contains string.
assert_attribute(selector, attr, value) sel, attr, val Asserts attribute value.

12. Scrolling & Waiting

Method Arguments Description
scroll_into_view(selector) selector Scrolls element into viewport.
scroll_to_bottom - Scrolls to page bottom.
scroll_to_top - Scrolls to page top.
scroll_down(amount:) amount: 25 Scrolls down X percent.
scroll_up(amount:) amount: 25 Scrolls up X percent.
scroll_to_y(y) y Scrolls to pixel Y position.
sleep(seconds) seconds Hard pause.
wait_for_element(selector, timeout:) selector, timeout Waits for element to exist.
wait_for_text(text, selector:, timeout:) text, sel, timeout Waits for text to exist.
wait_for_element_present(selector...) - Alias for wait_for_element.
wait_for_element_absent(selector, timeout:) selector, timeout Waits for element to go away.
wait_for_element_not_visible(...) - Waits for element to be hidden.

13. Screenshots & Files

Method Arguments Description
screenshot(filename:, selector:) filename, selector Saves PNG. Optional selector crops to element.
save_as_pdf(filename:) filename Saves page as PDF.
upload_file(selector, local_file_path) selector, path Uploads local file to file input.

14. Network Control

Method Arguments Description
block_urls(patterns) patterns (Array) Blocks URLs matching patterns.
wait_for_network_idle - Waits for network activity to settle.
get_performance_metrics - Returns Chrome performance logs.

15. Frames (iFrames)

Method Arguments Description
switch_to_frame(selector) selector Switches context to iframe.
switch_to_default_content - Switches back to main page.
switch_to_parent_frame - Switches to parent frame.

16. Alerts & Dialogs

Method Arguments Description
accept_alert - Clicks OK on alert/confirm.
dismiss_alert - Clicks Cancel on confirm.
get_alert_text - Gets text of alert popup.

17. Session & Viewport

Method Arguments Description
export_session - Returns session state (cookies/storage).
import_session(state_dict) state_dict Loads a session state.
execute_cdp_cmd(cmd, params:) cmd, params Executes raw Chrome DevTools command.

License

This project is licensed under the MIT License.


Built for the Sovereign Web. Powered by isoAutomate.

Official WebsiteFull API ReferenceSupport