Handle iOS device-related commands. Returns: True if a device command was handled (should exit), False otherwise.
(args)
| 525 | |
| 526 | |
| 527 | def handle_ios_device_commands(args) -> bool: |
| 528 | """ |
| 529 | Handle iOS device-related commands. |
| 530 | |
| 531 | Returns: |
| 532 | True if a device command was handled (should exit), False otherwise. |
| 533 | """ |
| 534 | conn = XCTestConnection(wda_url=args.wda_url) |
| 535 | |
| 536 | # Handle --list-devices |
| 537 | if args.list_devices: |
| 538 | devices = list_ios_devices() |
| 539 | if not devices: |
| 540 | print("No iOS devices connected.") |
| 541 | print("\nTroubleshooting:") |
| 542 | print(" 1. Connect device via USB") |
| 543 | print(" 2. Unlock device and trust this computer") |
| 544 | print(" 3. Run: idevice_id -l") |
| 545 | else: |
| 546 | print("Connected iOS devices:") |
| 547 | print("-" * 70) |
| 548 | for device in devices: |
| 549 | conn_type = device.connection_type.value |
| 550 | model_info = f"{device.model}" if device.model else "Unknown" |
| 551 | ios_info = f"iOS {device.ios_version}" if device.ios_version else "" |
| 552 | name_info = device.device_name or "Unnamed" |
| 553 | |
| 554 | print(f" ✓ {name_info}") |
| 555 | print(f" UUID: {device.device_id}") |
| 556 | print(f" Model: {model_info}") |
| 557 | print(f" OS: {ios_info}") |
| 558 | print(f" Connection: {conn_type}") |
| 559 | print("-" * 70) |
| 560 | return True |
| 561 | |
| 562 | # Handle --pair |
| 563 | if args.pair: |
| 564 | print("Pairing with iOS device...") |
| 565 | success, message = conn.pair_device(args.device_id) |
| 566 | print(f"{'✓' if success else '✗'} {message}") |
| 567 | return True |
| 568 | |
| 569 | # Handle --wda-status |
| 570 | if args.wda_status: |
| 571 | print(f"Checking WebDriverAgent status at {args.wda_url}...") |
| 572 | print("-" * 50) |
| 573 | |
| 574 | if conn.is_wda_ready(): |
| 575 | print("✓ WebDriverAgent is running") |
| 576 | |
| 577 | status = conn.get_wda_status() |
| 578 | if status: |
| 579 | print(f"\nStatus details:") |
| 580 | value = status.get("value", {}) |
| 581 | print(f" Session ID: {status.get('sessionId', 'N/A')}") |
| 582 | print(f" Build: {value.get('build', {}).get('time', 'N/A')}") |
| 583 | |
| 584 | current_app = value.get("currentApp", {}) |
no test coverage detected