diff --git a/desktop_env/evaluators/getters/chrome.py b/desktop_env/evaluators/getters/chrome.py index 602aec5..d0a8c3a 100644 --- a/desktop_env/evaluators/getters/chrome.py +++ b/desktop_env/evaluators/getters/chrome.py @@ -58,6 +58,7 @@ def get_info_from_website(env, config: Dict[Any, Any]) -> Any: server_port = env.server_port remote_debugging_url = f"http://{host}:{port}" backend_url = f"http://{host}:{server_port}" + use_proxy = env.current_use_proxy with sync_playwright() as p: # connect to remote Chrome instance try: @@ -65,10 +66,13 @@ def get_info_from_website(env, config: Dict[Any, Any]) -> Any: except Exception as e: # If the connection fails (e.g., the agent close the browser instance), start a new browser instance app = 'chromium' if 'arm' in platform.machine() else 'google-chrome' - payload = json.dumps({"command": [ + command = [ app, "--remote-debugging-port=1337" - ], "shell": False}) + ] + if use_proxy: + command.append(f"--proxy-server=127.0.0.1:18888") + payload = json.dumps({"command": command, "shell": False}) headers = {"Content-Type": "application/json"} #requests.post("http://" + host + ":" + server_port + "/setup" + "/launch", headers=headers, data=payload) requests.post(backend_url + "/setup" + "/launch", headers=headers, data=payload)