A Python module for automating interactions to mimic human behavior in standalone apps or browsers when using Selenium, Pyppeteer, or Playwright.
Project description
Emunium
Python library for human-like browser automation. Adds randomized mouse movements, realistic typing patterns, and smooth scrolling to Selenium, Pyppeteer, and Playwright. Also works standalone with image/OCR detection.
Installation
pip install emunium
For OCR support (standalone mode only):
pip install easyocr
Usage
Standalone mode
Uses image matching to find and interact with screen elements. Useful for automating desktop applications.
from emunium import Emunium, ClickType
emunium = Emunium()
# Find and type into a text field
elements = emunium.find_elements('field.png', min_confidence=0.8)
emunium.type_at(elements[0], 'Automating searches')
# Find and click search button
elements = emunium.find_elements('search_icon.png', min_confidence=0.8)
emunium.click_at(elements[0])
OCR text detection
Requires easyocr to be installed. Finds text on screen instead of using images.
from emunium import Emunium
emunium = Emunium(ocr=True, use_gpu=True, langs=['en'])
text_elements = emunium.find_text_elements('Submit', min_confidence=0.8)
if text_elements:
emunium.click_at(text_elements[0])
Selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from emunium import EmuniumSelenium
driver = webdriver.Chrome()
wait = WebDriverWait(driver, 10)
emunium = EmuniumSelenium(driver)
driver.get('https://duckduckgo.com/')
element = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '[data-state="suggesting"]')))
emunium.type_at(element, 'Automating searches')
submit = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '[aria-label="Search"]')))
emunium.click_at(submit)
driver.quit()
Pyppeteer
import asyncio
from pyppeteer import launch
from emunium import EmuniumPpeteer
async def main():
browser = await launch(headless=False)
page = await browser.newPage()
emunium = EmuniumPpeteer(page)
await page.goto('https://duckduckgo.com/')
element = await page.waitForSelector('[data-state="suggesting"]')
await emunium.type_at(element, 'Automating searches')
submit = await page.waitForSelector('[aria-label="Search"]')
await emunium.click_at(submit)
await browser.close()
asyncio.run(main())
Playwright
import asyncio
from playwright.async_api import async_playwright
from emunium import EmuniumPlaywright
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=False)
page = await browser.new_page()
emunium = EmuniumPlaywright(page)
await page.goto('https://duckduckgo.com/')
element = await page.wait_for_selector('[data-state="suggesting"]')
await emunium.type_at(element, 'Automating searches')
submit = await page.wait_for_selector('[aria-label="Search"]')
await emunium.click_at(submit)
await browser.close()
asyncio.run(main())
API
Mouse
move_to(element, offset_x=0, offset_y=0) - Moves cursor to element with bezier curves and random variations
click_at(element, click_type=ClickType.LEFT) - Clicks element after moving to it. Click types: LEFT, RIGHT, MIDDLE, DOUBLE
from emunium import ClickType
emunium.click_at(element) # left click
emunium.click_at(element, ClickType.RIGHT) # right click
emunium.click_at(element, ClickType.MIDDLE) # middle click
emunium.click_at(element, ClickType.DOUBLE) # double click
Keyboard
type_at(element, text, characters_per_minute=280, offset=20) - Types text with randomized delays between keystrokes
Scroll
scroll_to(element) - Smoothly scrolls element into view
Element detection (standalone only)
find_elements(image_path, min_confidence=0.8, target_width=None, target_height=None, max_elements=None) - Finds elements on screen by matching image template
find_text_elements(text, min_confidence=0.8, max_elements=None) - Finds text on screen using OCR (requires ocr=True in constructor)
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file emunium-2.2.0.tar.gz.
File metadata
- Download URL: emunium-2.2.0.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4010bbb635fecb3028cc9774445e1efe1d6b90fc9808b3fa1042efee5492f3ef
|
|
| MD5 |
2240421c816f7124c369bb7259dff0b8
|
|
| BLAKE2b-256 |
7880991254ba6f9b8b5a8e490b525820f51418f9ada582689f52d632ec243ace
|
File details
Details for the file emunium-2.2.0-py3-none-any.whl.
File metadata
- Download URL: emunium-2.2.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e33bd0acec6b1ab3a90e70011f4758441f314319d949265d37836be7fd303404
|
|
| MD5 |
b8412583ce577d35e07f3e2d1bc9679e
|
|
| BLAKE2b-256 |
752f2bb0651028977f4488868068d92a4785d4dbe3860df1d1ba72d491fa9fd8
|