Check system requirements before running the agent. Checks: 1. libimobiledevice tools installed 2. At least one iOS device connected 3. WebDriverAgent is running Args: wda_url: WebDriverAgent URL to check. Returns: True if all checks pass, False otherw
(wda_url: str = "http://localhost:8100")
| 29 | |
| 30 | |
| 31 | def check_system_requirements(wda_url: str = "http://localhost:8100") -> bool: |
| 32 | """ |
| 33 | Check system requirements before running the agent. |
| 34 | |
| 35 | Checks: |
| 36 | 1. libimobiledevice tools installed |
| 37 | 2. At least one iOS device connected |
| 38 | 3. WebDriverAgent is running |
| 39 | |
| 40 | Args: |
| 41 | wda_url: WebDriverAgent URL to check. |
| 42 | |
| 43 | Returns: |
| 44 | True if all checks pass, False otherwise. |
| 45 | """ |
| 46 | print("🔍 Checking system requirements...") |
| 47 | print("-" * 50) |
| 48 | |
| 49 | all_passed = True |
| 50 | |
| 51 | # Check 1: libimobiledevice installed |
| 52 | print("1. Checking libimobiledevice installation...", end=" ") |
| 53 | if shutil.which("idevice_id") is None: |
| 54 | print("❌ FAILED") |
| 55 | print(" Error: libimobiledevice is not installed or not in PATH.") |
| 56 | print(" Solution: Install libimobiledevice:") |
| 57 | print(" - macOS: brew install libimobiledevice") |
| 58 | print(" - Linux: sudo apt-get install libimobiledevice-utils") |
| 59 | all_passed = False |
| 60 | else: |
| 61 | # Double check by running idevice_id |
| 62 | try: |
| 63 | result = subprocess.run( |
| 64 | ["idevice_id", "-ln"], capture_output=True, text=True, timeout=10 |
| 65 | ) |
| 66 | if result.returncode == 0: |
| 67 | print("✅ OK") |
| 68 | else: |
| 69 | print("❌ FAILED") |
| 70 | print(" Error: idevice_id command failed to run.") |
| 71 | all_passed = False |
| 72 | except FileNotFoundError: |
| 73 | print("❌ FAILED") |
| 74 | print(" Error: idevice_id command not found.") |
| 75 | all_passed = False |
| 76 | except subprocess.TimeoutExpired: |
| 77 | print("❌ FAILED") |
| 78 | print(" Error: idevice_id command timed out.") |
| 79 | all_passed = False |
| 80 | |
| 81 | # If libimobiledevice is not installed, skip remaining checks |
| 82 | if not all_passed: |
| 83 | print("-" * 50) |
| 84 | print("❌ System check failed. Please fix the issues above.") |
| 85 | return False |
| 86 | |
| 87 | # Check 2: iOS Device connected |
| 88 | print("2. Checking connected iOS devices...", end=" ") |
no test coverage detected