microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.64k stars 3.65k forks source link

[BUG] Unable to connect to Dolphin Anty #18935

Closed ESPodmov closed 1 year ago

ESPodmov commented 1 year ago
import asyncio
import requests
from playwright.async_api import async_playwright
import DolphinController

async def run(playwright):
    session = requests.session()
    auth_token = DolphinController.authentication("login", "password")
    headers = {
        "Authorization": f"Bearer {auth_token}",
        "Content-Type": "application/json"
    }
    session.headers = headers
    current_profile_id = DolphinController.create_profile_and_send_id(session)
    automation_json = DolphinController.start_automation(session, profile_id=current_profile_id)
    dolphin_port = automation_json["automation"]["port"]
    dolphin_ws_endpoint = automation_json["automation"]["wsEndpoint"]
    chromium = playwright.chromium
    browser = await chromium.connect_over_cdp(f"ws://127.0.0.1:{dolphin_port}{dolphin_ws_endpoint}")
    context = browser.contexts[0]
    await context.close()
    context = await browser.new_context()
    page = context.pages[0]
    await page.goto("http://google.com")
    # other actions...
    await browser.close()

async def main():
    async with async_playwright() as playwright:
        await run(playwright)

asyncio.run(main())

Unable to connect to the Dolphin Anty using playwright.chromium.connect_over_cdp() function All that turned out to be found out is that in order for automation to go as it should, you need to open a new tab and close the start one DolphinController class just opens new instance of Dolphin browser P.S. DolphinController working correctly P.P.S. I tested this class with another library

dgozman commented 1 year ago

@ESPodmov

dgozman commented 1 year ago

Closing because we lack the information to act on this issue. If you can provide a full repro, please file a new issue with it, and link to this one.