Loading...
Loading...
Automates Google Chrome and Chromium-based browsers via JXA with AppleScript dictionary discovery. Use when asked to "automate Chrome tabs", "control browser with JXA", "Chrome AppleScript automation", "Chromium browser scripting", or "browser tab management". Covers windows, tabs, execute(), tunneling patterns, and permissions.
npx skill4agent add spillwavesolutions/automating-mac-apps-plugin automating-chromeweb-browser-automationautomating-mac-appsautomating-mac-appsexecute()execute()navigator.clipboard.writeText()localStorage.setItem()execute()chrome.running()const chrome = Application('Google Chrome');
chrome.windows[0].tabs.push(chrome.Tab());
chrome.windows[0].tabs[chrome.windows[0].tabs.length - 1].url = 'https://example.com';const result = chrome.execute({javascript: 'document.title'});
// Note: execute() runs JS but doesn't reliably return valuesconst tabs = chrome.windows[0].tabs;
for (let i = tabs.length - 1; i >= 0; i--) {
if (tabs[i].url().includes('unwanted')) {
tabs[i].close();
}
}// Inject script to save title to localStorage
chrome.execute({javascript: 'localStorage.setItem("pageTitle", document.title)'});
// Retrieve via another execute call
chrome.execute({javascript: 'console.log(localStorage.getItem("pageTitle"))'});try {
const chrome = Application('Google Chrome');
chrome.windows[0].tabs[0].url(); // Test access
console.log('Permissions OK');
} catch (error) {
console.log('Permission error:', error.message);
}web-browser-automationimport PyXA
# Launch Chrome and navigate
chrome = PyXA.Application("Google Chrome")
chrome.activate()
chrome.open_location("https://example.com")
# Get current tab info
current_tab = chrome.current_tab()
print(f"Page title: {current_tab.title()}")
print(f"Current URL: {current_tab.url()}")from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from AppKit import NSWorkspace
# Configure Chrome options
options = Options()
options.add_argument("--remote-debugging-port=9222")
options.add_argument('--headless=new') # Modern headless mode
# Launch Chrome with Selenium (automatic ChromeDriver management)
driver = webdriver.Chrome(options=options)
driver.get('https://example.com')
# macOS integration via PyObjC
workspace = NSWorkspace.sharedWorkspace()
frontmost_app = workspace.frontmostApplication()
print(f"Frontmost app: {frontmost_app.localizedName()}")
print(f"Page title: {driver.title}")
driver.quit()# Install Selenium (latest: 4.38.0)
pip install selenium
# ChromeDriver is automatically managed by Selenium Manager (v4.11+)
# No manual download needed - compatible version downloaded automatically
# Basic Python example
from selenium import webdriver
driver = webdriver.Chrome() # Automatic ChromeDriver management
driver.get('https://example.com')
print(driver.title)
driver.quit()from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless=new') # Modern headless mode (required)
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(options=options)
driver.get('https://example.com')
print(f"Page title: {driver.title}")
driver.quit()from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
# Download from https://googlechromelabs.github.io/chromedriver/
# Match major version with your Chrome installation
service = Service(executable_path='/path/to/chromedriver')
options = Options()
driver = webdriver.Chrome(service=service, options=options)# Install Puppeteer (latest: 24.35.0)
npm install puppeteer
# Bundles compatible Chrome automaticallyconst puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
headless: 'new' // Modern headless mode (required in v24+)
});
const page = await browser.newPage();
await page.goto('https://example.com');
const title = await page.title();
console.log(title);
await browser.close();
})();const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
headless: 'new',
args: ['--no-sandbox', '--disable-dev-shm-usage']
});
const page = await browser.newPage();
// Set viewport
await page.setViewport({ width: 1280, height: 720 });
await page.goto('https://example.com');
// Wait for element and interact
await page.waitForSelector('h1');
const title = await page.title();
console.log(`Page title: ${title}`);
await browser.close();
})();// WebSocket connection to CDP
const WebSocket = require('ws');
const ws = new WebSocket('ws://localhost:9222/devtools/page/{page-id}');
// Send CDP commands
ws.send(JSON.stringify({
id: 1,
method: 'Runtime.evaluate',
params: { expression: 'document.title' }
}));npm install puppeteer--remote-debugging-port=9222chrome.running()automating-chrome/references/chrome-basics.mdautomating-chrome/references/chrome-recipes.mdautomating-chrome/references/chrome-advanced.mdautomating-chrome/references/chrome-dictionary.mdautomating-chrome/references/chromium-browser-names.mdautomating-chrome/references/chrome-form-automation.mdweb-browser-automationautomating-mac-apps