Recording SDK
Launch Chrome and capture interactions entirely from Python—no manual extension clicks needed.
Control when recording starts and stops directly from your automation scripts (Playwright, Selenium, etc.) to capture user interactions and build reusable workflows.
Setup
First, ensure you have the InverseUI Chrome extension installed and your authentication token configured.
Configuration
# config.py
EXTENSION_PATH = "/path/to/InverseUI-Chrome-Extension/"
EXTENSION_ID = "your_extension_id"
# Your authentication token
INVERSEUI_AUTH_TOKEN = "your_auth_token_here"
INVERSEUI_AUTH_COOKIE = {
"domain": ".inverseui.com",
"name": "inverseui_auth_token",
"value": INVERSEUI_AUTH_TOKEN,
"path": "/",
"secure": True,
"httpOnly": False,
"sameSite": "strict"
}Starting a Recording
Control when to start recording browser actions from your Python automation script.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import time
# Set up Chrome with InverseUI extension
options = webdriver.ChromeOptions()
options.add_argument(f'--load-extension={EXTENSION_PATH}')
options.add_argument('--disable-blink-features=AutomationControlled')
driver = webdriver.Chrome(service=Service(), options=options)
# Add authentication cookie
driver.get("https://inverseui.com")
driver.add_cookie(INVERSEUI_AUTH_COOKIE)
# Start recording via extension API
driver.execute_script("""
chrome.runtime.sendMessage(
'""" + EXTENSION_ID + """',
{ action: 'START_RECORDING' },
(response) => { console.log('Recording started:', response); }
);
""")
time.sleep(2) # Wait for recording to start
# Your automation code here
driver.get("https://example.com")
# ... perform actions ...Stopping Recording & Fetching Actions
After your automation completes, stop the recording and retrieve all captured actions.
# Stop the recording
driver.execute_script("""
chrome.runtime.sendMessage(
'""" + EXTENSION_ID + """',
{ action: 'STOP_RECORDING' },
(response) => { console.log('Recording stopped:', response); }
);
""")
time.sleep(1)
# Fetch captured actions
actions = driver.execute_script("""
return new Promise((resolve) => {
chrome.runtime.sendMessage(
'""" + EXTENSION_ID + """',
{ action: 'GET_ACTIONS' },
(response) => { resolve(response); }
);
});
""")
# Process the captured actions
if actions and 'actions' in actions:
for action in actions['actions']:
print(f"Action: {action['browserAction']}")
print(f" Timestamp: {action['timestamp']}")
print(f" XPath: {action.get('xpath', 'N/A')}")
print(f" Content: {action.get('content', 'N/A')}")
print()Full Example
Complete example that starts a recording, performs actions, and saves the captured data:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from config import EXTENSION_PATH, EXTENSION_ID, INVERSEUI_AUTH_COOKIE
import time
import json
def main():
# Setup Chrome with extension
options = webdriver.ChromeOptions()
options.add_argument(f'--load-extension={EXTENSION_PATH}')
options.add_argument('--disable-blink-features=AutomationControlled')
driver = webdriver.Chrome(service=Service(), options=options)
try:
# Authenticate
driver.get("https://inverseui.com")
driver.add_cookie(INVERSEUI_AUTH_COOKIE)
# Start recording
driver.execute_script(f"""
chrome.runtime.sendMessage('{EXTENSION_ID}',
{{ action: 'START_RECORDING' }});
""")
time.sleep(2)
# Perform your automation
driver.get("https://example.com")
# ... your actions here ...
# Stop recording
driver.execute_script(f"""
chrome.runtime.sendMessage('{EXTENSION_ID}',
{{ action: 'STOP_RECORDING' }});
""")
time.sleep(1)
# Fetch and save actions
actions = driver.execute_script(f"""
return new Promise((resolve) => {{
chrome.runtime.sendMessage('{EXTENSION_ID}',
{{ action: 'GET_ACTIONS' }},
(response) => resolve(response));
}});
""")
# Save to file
with open('recorded_actions.json', 'w') as f:
json.dump(actions, f, indent=2)
print(f"Recorded {len(actions.get('actions', []))} actions")
finally:
driver.quit()
if __name__ == "__main__":
main()