brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.84k stars 2.33k forks source link

Unable to launch Brave In Tor Mode using Microsoft Playwright #32403

Open zibdie opened 1 year ago

zibdie commented 1 year ago

Description

I am trying to combine Microsoft Playwright with Brave for testing but unable to launch Brave using Tor. I can launch it normally but cannot with Tor when passing the arguments. Using a Mac

Steps to Reproduce

  1. Attempt to launch Brave by passing Tor arg in Playwright
  2. Visit a website like check.torproject.org
  3. See that you are not on tor
# pip install pytest-playwright playwright
import sys, time
from playwright.sync_api import Playwright, sync_playwright, expect

def getBraveBrowserPath():
    if sys.platform == "win32":
        return "C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe"
    elif sys.platform == "linux":
        return "/usr/bin/brave-browser"
    elif sys.platform == "darwin":
        return "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"

def run(playwright):
    browser = playwright.chromium.launch(
        executable_path=getBraveBrowserPath(),
        args=["--incognito", "--tor"],
        headless=False,
    )
    context = browser.new_context()
    page = context.new_page()
    page.goto("https://check.torproject.org/")
    time.sleep(10)
    context.close()
    browser.close()

with sync_playwright() as playwright:
    run(playwright)

Actual result:

Not using Tor

Expected result:

Should be using Tor

Reproduces how often:

Every time

Brave version (brave://version info)

1.56.20 Chromium: 115.0.5790.171 (Official Build) (arm64) 

cf9067bf10d8f798c24643029af1d24e275646d6-refs/branch-heads/5790@{#1924}

/Applications/Brave Browser.app/Contents/MacOS/Brave Browser --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --enable-use-zoom-for-dsf=false --no-sandbox --incognito --tor --user-data-dir=/var/folders/z5/qdcdd9113yx3h2hp1rb0yc100000gn/T/playwright_chromiumdev_profile-Keiiuo --remote-debugging-pipe --no-startup-window --disable-domain-reliability --enable-dom-distiller --origin-trial-public-key=bYUKPJoPnCxeNvu72j4EmPuK7tr1PAC7SHh8ld9Mw3E=,fMS4mpO6buLQ/QMd+zJmxzty/VQ6B1EUZqoCU04zoRU= --sync-url=https://sync-v2.brave.com/v2 --lso-url=https://no-thanks.invalid --variations-server-url=https://variations.brave.com/seed --variations-insecure-server-url=https://variations.brave.com/seed --enable-features=NetworkServiceInProcess,NetworkService --disable-features=CertificateTransparencyComponentUpdater,DialMediaRouteProvider,AvoidUnnecessaryBeforeUnloadCheckSync,MediaRouter,AutoExpandDetailsElement,DestroyProfileOnBrowserClose,GlobalMediaControls,LazyFrameLoading,Translate,AcceptCHFrame,ImprovedCookieControls --flag-switches-begin --flag-switches-end --component-updater=url-source=https://go-updater.brave.com/extensions

Version/Channel Information:

Other Additional Information:

Miscellaneous Information:

abdeljalil09 commented 7 months ago

it work using launch_persistent_context with arg "--tor"

`from playwright.sync_api import sync_playwright import os

user_dir = 'tmp/playwright' user_dir = os.path.join(os.getcwd(), user_dir)

with sync_playwright() as p: browser = p.chromium.launch_persistent_context(user_dir, headless=False) page = browser.new_page() page.goto('https://playwright.dev/python', wait_until='domcontentloaded')`