Installation Guide
This guide will help you install and set up BrowserJQuery for your project.
Requirements
Python 3.8 or higher
Selenium WebDriver
Chrome or Firefox browser
Installation
Using pip
pip install browserjquery
Using Poetry
poetry add browserjquery
From Source
Clone the repository:
git clone https://github.com/yourusername/browserjquery.git
cd browserjquery
Install dependencies:
pip install -r requirements.txt
Install the package:
pip install -e .
Setting Up Selenium WebDriver
Chrome WebDriver
Install Chrome browser if not already installed
Download ChromeDriver from ChromeDriver Downloads
Add ChromeDriver to your system PATH
Firefox WebDriver
Install Firefox browser if not already installed
Download geckodriver from geckodriver Releases
Add geckodriver to your system PATH
Basic Setup
from browserjquery import BrowserJQuery
from selenium import webdriver
# Initialize Chrome WebDriver
driver = webdriver.Chrome()
# Or Firefox
# driver = webdriver.Firefox()
# Create BrowserJQuery instance
browser = BrowserJQuery(driver)
# Navigate to a page
driver.get("https://example.com")
# Start using BrowserJQuery
elements = browser.find(".my-class")
Configuration
WebDriver Options
from selenium.webdriver.chrome.options import Options
# Configure Chrome options
options = Options()
options.add_argument("--headless") # Run in headless mode
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
# Initialize with options
driver = webdriver.Chrome(options=options)
browser = BrowserJQuery(driver)
jQuery Injection
BrowserJQuery automatically injects jQuery into pages. You can control this behavior:
# Check if jQuery is injected
if browser.is_jquery_injected:
print("jQuery is available")
# Manually inject jQuery
browser.inject_jquery(by="file") # From local file
browser.inject_jquery(by="cdn") # From CDN
Troubleshooting
Common Issues
WebDriver not found
Ensure WebDriver is installed and in your system PATH
Try specifying the WebDriver path explicitly:
from selenium.webdriver.chrome.service import Service service = Service(path="/path/to/chromedriver") driver = webdriver.Chrome(service=service)
jQuery injection fails
Check if the page already has jQuery
Try using a different injection method (file vs CDN)
Ensure the page is fully loaded before injection
Element not found
Verify the selector syntax
Check if the element is in an iframe
Ensure the element is visible and loaded
Getting Help
Check the API Reference for detailed documentation
Look at Examples for usage patterns
Open an issue on GitHub for bugs or feature requests