feat: enhance evaluator configuration for Chrome with post-execution commands

- Added postconfig commands to multiple JSON files for Chrome evaluation examples.
- Included commands to terminate existing Chrome processes, launch Chrome with remote debugging, and introduce sleep intervals for timing.
- Updated logging messages in the AWS manager to improve clarity and user experience.

These changes enhance the automation and usability of the evaluation examples while preserving existing logic.
This commit is contained in:
yuanmengqi
2025-07-17 10:50:10 +00:00
parent 24fbad9015
commit 2c51950e73
12 changed files with 172 additions and 59 deletions

View File

@@ -128,7 +128,6 @@ def _allocate_vm(region=DEFAULT_REGION, screen_size=(1920, 1080)):
waiter.wait(InstanceIds=[instance_id])
logger.info(f"Instance {instance_id} is ready.")
# 获取并显示VNC访问地址
try:
instance_details = ec2_client.describe_instances(InstanceIds=[instance_id])
instance = instance_details['Reservations'][0]['Instances'][0]
@@ -140,8 +139,8 @@ def _allocate_vm(region=DEFAULT_REGION, screen_size=(1920, 1080)):
logger.info(f"📡 Public IP: {public_ip}")
logger.info(f"🆔 Instance ID: {instance_id}")
logger.info("="*80)
print(f"\n🌐 VNC访问地址: {vnc_url}")
print(f"📍 请在浏览器中打开上述地址进行远程桌面访问\n")
print(f"\n🌐 VNC Web Access URL: {vnc_url}")
print(f"📍 Please open the above address in the browser for remote desktop access\n")
except Exception as e:
logger.warning(f"Failed to get VNC address for instance {instance_id}: {e}")
except KeyboardInterrupt:

View File

@@ -29,6 +29,32 @@
"chrome"
],
"evaluator": {
"postconfig": [
{
"type": "launch",
"parameters": {
"command": [
"pkill",
"chrome"
]
}
},
{
"type": "launch",
"parameters": {
"command": [
"google-chrome",
"--remote-debugging-port=1337"
]
}
},
{
"type": "sleep",
"parameters": {
"seconds": 3
}
}
],
"func": "exact_match",
"result": {
"type": "enable_do_not_track"

View File

@@ -29,6 +29,32 @@
"chrome"
],
"evaluator": {
"postconfig": [
{
"type": "launch",
"parameters": {
"command": [
"pkill",
"chrome"
]
}
},
{
"type": "launch",
"parameters": {
"command": [
"google-chrome",
"--remote-debugging-port=1337"
]
}
},
{
"type": "sleep",
"parameters": {
"seconds": 3
}
}
],
"func": "is_expected_bookmarks",
"result": {
"type": "bookmarks"

View File

@@ -47,6 +47,12 @@
"--remote-debugging-port=1337"
]
}
},
{
"type": "sleep",
"parameters": {
"seconds": 3
}
}
],
"func": "exact_match",

View File

@@ -254,6 +254,12 @@
"--remote-debugging-port=1337"
]
}
},
{
"type": "sleep",
"parameters": {
"seconds": 3
}
}
],
"func": "check_history_deleted",

View File

@@ -47,6 +47,12 @@
"--remote-debugging-port=1337"
]
}
},
{
"type": "sleep",
"parameters": {
"seconds": 3
}
}
],
"func": "check_enabled_experiments",

View File

@@ -38,6 +38,32 @@
"chrome"
],
"evaluator": {
"postconfig": [
{
"type": "launch",
"parameters": {
"command": [
"pkill",
"chrome"
]
}
},
{
"type": "launch",
"parameters": {
"command": [
"google-chrome",
"--remote-debugging-port=1337"
]
}
},
{
"type": "sleep",
"parameters": {
"seconds": 3
}
}
],
"func": "is_expected_bookmarks",
"result": {
"type": "bookmarks"

View File

@@ -38,6 +38,32 @@
"chrome"
],
"evaluator": {
"postconfig": [
{
"type": "launch",
"parameters": {
"command": [
"pkill",
"chrome"
]
}
},
{
"type": "launch",
"parameters": {
"command": [
"google-chrome",
"--remote-debugging-port=1337"
]
}
},
{
"type": "sleep",
"parameters": {
"seconds": 3
}
}
],
"func": "is_cookie_deleted",
"result": {
"type": "cookie_data",

View File

@@ -31,10 +31,27 @@
"evaluator": {
"postconfig": [
{
"type": "execute",
"type": "launch",
"parameters": {
"command": "pkill chrome",
"shell": "true"
"command": [
"pkill",
"chrome"
]
}
},
{
"type": "launch",
"parameters": {
"command": [
"google-chrome",
"--remote-debugging-port=1337"
]
}
},
{
"type": "sleep",
"parameters": {
"seconds": 3
}
}
],

View File

@@ -31,10 +31,27 @@
"evaluator": {
"postconfig": [
{
"type": "execute",
"type": "launch",
"parameters": {
"command": "pkill chrome",
"shell": "true"
"command": [
"pkill",
"chrome"
]
}
},
{
"type": "launch",
"parameters": {
"command": [
"google-chrome",
"--remote-debugging-port=1337"
]
}
},
{
"type": "sleep",
"parameters": {
"seconds": 3
}
}
],

View File

@@ -47,6 +47,12 @@
"--remote-debugging-port=1337"
]
}
},
{
"type": "sleep",
"parameters": {
"seconds": 3
}
}
],
"func": "check_font_size",

View File

@@ -31,28 +31,11 @@
"evaluator": {
"postconfig": [
{
"type": "execute",
"parameters": {
"command": [
"python3",
"-c",
"import pyautogui; pyautogui.press('f5')"
]
}
},
{
"type": "sleep",
"parameters": {
"seconds": 3
}
},
{
"type": "execute",
"type": "launch",
"parameters": {
"command": [
"pkill",
"-f",
"google-chrome"
"chrome"
]
}
},
@@ -65,37 +48,6 @@
]
}
},
{
"type": "launch",
"parameters": {
"command": [
"socat",
"tcp-listen:9222,fork",
"tcp:localhost:1337"
]
}
},
{
"type": "chrome_open_tabs",
"parameters": {
"urls_to_open": [
"chrome://settings/search",
"chrome://settings"
]
}
},
{
"type": "sleep",
"parameters": {
"seconds": 3
}
},
{
"type": "execute",
"parameters": {
"command": ["pkill", "-SIGHUP", "-f", "google-chrome"]
}
},
{
"type": "sleep",
"parameters": {