add iOS support (#358)
* ios * tests * docs * real device * better list * fixes
This commit is contained in:
+121
-2
@@ -78,6 +78,53 @@ pub fn print_response(resp: &Response, json_mode: bool, action: Option<&str>) {
|
||||
);
|
||||
return;
|
||||
}
|
||||
// iOS Devices
|
||||
if let Some(devices) = data.get("devices").and_then(|v| v.as_array()) {
|
||||
if devices.is_empty() {
|
||||
println!("No iOS devices available. Open Xcode to download simulator runtimes.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Separate real devices from simulators
|
||||
let real_devices: Vec<_> = devices
|
||||
.iter()
|
||||
.filter(|d| d.get("isRealDevice").and_then(|v| v.as_bool()).unwrap_or(false))
|
||||
.collect();
|
||||
let simulators: Vec<_> = devices
|
||||
.iter()
|
||||
.filter(|d| !d.get("isRealDevice").and_then(|v| v.as_bool()).unwrap_or(false))
|
||||
.collect();
|
||||
|
||||
if !real_devices.is_empty() {
|
||||
println!("Connected Devices:\n");
|
||||
for device in real_devices.iter() {
|
||||
let name = device.get("name").and_then(|v| v.as_str()).unwrap_or("Unknown");
|
||||
let runtime = device.get("runtime").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let udid = device.get("udid").and_then(|v| v.as_str()).unwrap_or("");
|
||||
println!(" {} {} ({})", color::green("●"), name, runtime);
|
||||
println!(" {}", color::dim(udid));
|
||||
}
|
||||
println!();
|
||||
}
|
||||
|
||||
if !simulators.is_empty() {
|
||||
println!("Simulators:\n");
|
||||
for device in simulators.iter() {
|
||||
let name = device.get("name").and_then(|v| v.as_str()).unwrap_or("Unknown");
|
||||
let runtime = device.get("runtime").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let state = device.get("state").and_then(|v| v.as_str()).unwrap_or("Unknown");
|
||||
let udid = device.get("udid").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let state_indicator = if state == "Booted" {
|
||||
color::green("●")
|
||||
} else {
|
||||
color::dim("○")
|
||||
};
|
||||
println!(" {} {} ({})", state_indicator, name, runtime);
|
||||
println!(" {}", color::dim(udid));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Tabs
|
||||
if let Some(tabs) = data.get("tabs").and_then(|v| v.as_array()) {
|
||||
for (i, tab) in tabs.iter().enumerate() {
|
||||
@@ -1551,6 +1598,68 @@ Examples:
|
||||
"##
|
||||
}
|
||||
|
||||
// === iOS Commands ===
|
||||
"tap" => {
|
||||
r##"
|
||||
agent-browser tap - Tap an element (touch gesture)
|
||||
|
||||
Usage: agent-browser tap <selector>
|
||||
|
||||
Taps an element. This is an alias for 'click' that provides semantic clarity
|
||||
for touch-based interfaces like iOS Safari.
|
||||
|
||||
Options:
|
||||
--json Output as JSON
|
||||
--session <name> Use specific session
|
||||
|
||||
Examples:
|
||||
agent-browser tap "#submit-button"
|
||||
agent-browser tap @e1
|
||||
agent-browser -p ios tap "button:has-text('Sign In')"
|
||||
"##
|
||||
}
|
||||
"swipe" => {
|
||||
r##"
|
||||
agent-browser swipe - Swipe gesture (iOS)
|
||||
|
||||
Usage: agent-browser swipe <direction> [distance]
|
||||
|
||||
Performs a swipe gesture on iOS Safari. The direction determines
|
||||
which way the content moves (swipe up scrolls down, etc.).
|
||||
|
||||
Arguments:
|
||||
direction up, down, left, or right
|
||||
distance Optional distance in pixels (default: 300)
|
||||
|
||||
Options:
|
||||
--json Output as JSON
|
||||
--session <name> Use specific session
|
||||
|
||||
Examples:
|
||||
agent-browser -p ios swipe up
|
||||
agent-browser -p ios swipe down 500
|
||||
agent-browser -p ios swipe left
|
||||
"##
|
||||
}
|
||||
"device" => {
|
||||
r##"
|
||||
agent-browser device - Manage iOS simulators
|
||||
|
||||
Usage: agent-browser device <subcommand>
|
||||
|
||||
Subcommands:
|
||||
list List available iOS simulators
|
||||
|
||||
Options:
|
||||
--json Output as JSON
|
||||
--session <name> Use specific session
|
||||
|
||||
Examples:
|
||||
agent-browser device list
|
||||
agent-browser -p ios device list
|
||||
"##
|
||||
}
|
||||
|
||||
_ => return false,
|
||||
};
|
||||
println!("{}", help.trim());
|
||||
@@ -1660,7 +1769,8 @@ Options:
|
||||
--proxy-bypass <hosts> Bypass proxy for these hosts (or AGENT_BROWSER_PROXY_BYPASS)
|
||||
e.g., --proxy-bypass "localhost,*.internal.com"
|
||||
--ignore-https-errors Ignore HTTPS certificate errors
|
||||
-p, --provider <name> Cloud browser provider (or AGENT_BROWSER_PROVIDER env)
|
||||
-p, --provider <name> Browser provider: ios, browserbase, kernel, browseruse
|
||||
--device <name> iOS device name (e.g., "iPhone 15 Pro")
|
||||
--json JSON output
|
||||
--full, -f Full page screenshot
|
||||
--headed Show browser window (not headless)
|
||||
@@ -1671,8 +1781,10 @@ Options:
|
||||
Environment:
|
||||
AGENT_BROWSER_SESSION Session name (default: "default")
|
||||
AGENT_BROWSER_EXECUTABLE_PATH Custom browser executable path
|
||||
AGENT_BROWSER_PROVIDER Cloud browser provider
|
||||
AGENT_BROWSER_PROVIDER Browser provider (ios, browserbase, kernel, browseruse)
|
||||
AGENT_BROWSER_STREAM_PORT Enable WebSocket streaming on port (e.g., 9223)
|
||||
AGENT_BROWSER_IOS_DEVICE Default iOS device name
|
||||
AGENT_BROWSER_IOS_UDID Default iOS device UDID
|
||||
|
||||
Examples:
|
||||
agent-browser open example.com
|
||||
@@ -1684,6 +1796,13 @@ Examples:
|
||||
agent-browser screenshot --full
|
||||
agent-browser --cdp 9222 snapshot # Connect via CDP port
|
||||
agent-browser --profile ~/.myapp open example.com # Persistent profile
|
||||
|
||||
iOS Simulator (requires Xcode and Appium):
|
||||
agent-browser -p ios open example.com # Use default iPhone
|
||||
agent-browser -p ios --device "iPhone 15 Pro" open url # Specific device
|
||||
agent-browser -p ios device list # List simulators
|
||||
agent-browser -p ios swipe up # Swipe gesture
|
||||
agent-browser -p ios tap @e1 # Touch element
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user