MartinooCoco
MartinooCoco

Reputation: 1

Automating Extension Interaction in Chromium with Python

I'm currently developing a Python script with the goal of automating the activation of the an extension within a Chromium environment. The script's purpose is to streamline the process of refreshing proxies, launching and activating the extension, and then closing the browser. This would greatly optimize the workflow across my 40+ GoLogin profiles, which I am currently handling manually.

However, I've encountered a challenge: it seems that Pyppeteer is unable to initiate a click on the extension's icon, and simulating keyboard shortcuts isn't triggering the extension either.

I'm reaching out to seek any advice or insights on interacting with a Chrome extension within an automated browser setup like AntiBrowser. Has anyone faced a similar challenge, or can anyone suggest alternative methods for automating extension interactions?

Cheers !

import asyncio
from pyppeteer import connect

async def perform_actions(ws_url):
    try:
        
        browser = await connect(browserWSEndpoint=ws_url)
        pages = await browser.pages()
        page = pages[0]  
        await asyncio.sleep(2)

        await page.focus('body')

        await asyncio.sleep(1)

        
        await page.keyboard.down('Control')
     
        await page.keyboard.press('S')
       
        await page.keyboard.up('Control')

        await asyncio.sleep(1)

        print("Actions performed on the existing browser session.")
    except Exception as e:
        print(f"An error occurred: {e}")
    finally:
        await browser.disconnect()

I'm getting the ws URL from the multilogins software.

Upvotes: 0

Views: 157

Answers (0)

Related Questions