Skip to content

Commit 6e38479

Browse files
author
mdshakib007
committed
bundle id is now extracting from the xml file
1 parent 9336c72 commit 6e38479

6 files changed

Lines changed: 16 additions & 407 deletions

File tree

server/mobile.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Literal
77
import asyncio
88
import socket
9+
import xml.etree.ElementTree as ET
910

1011
import requests
1112
from fastapi import APIRouter
@@ -39,6 +40,7 @@ class InspectorResponse(BaseModel):
3940
status: Literal["ok", "error"] = "ok"
4041
ui_xml: str | None = None
4142
screenshot: str | None = None # Base64 encoded image
43+
bundle_identifier: str | None = None
4244
error: str | None = None
4345

4446

@@ -178,6 +180,14 @@ def start_ios_services():
178180
return {"status": "error", "error": str(e)}
179181

180182

183+
def extract_bundle_id_from_xml(xml_content: str) -> str | None:
184+
try:
185+
root = ET.fromstring(xml_content)
186+
return root.get('bundleId')
187+
except Exception:
188+
return None
189+
190+
181191
@router.get("/ios/inspect")
182192
def inspect_ios(device_udid: str | None = None):
183193
"""Get iOS simulator screenshot and XML hierarchy."""
@@ -204,6 +214,9 @@ def inspect_ios(device_udid: str | None = None):
204214

205215
with open(IOS_XML_PATH, 'r', encoding='utf-8') as xml_file:
206216
xml_content = xml_file.read()
217+
218+
# Extract bundle identifier from XML content
219+
bundle_id = extract_bundle_id_from_xml(xml_content)
207220

208221
with open(IOS_SCREENSHOT_PATH, 'rb') as img_file:
209222
screenshot_bytes = img_file.read()
@@ -212,7 +225,8 @@ def inspect_ios(device_udid: str | None = None):
212225
return InspectorResponse(
213226
status="ok",
214227
ui_xml=xml_content,
215-
screenshot=screenshot_base64
228+
screenshot=screenshot_base64,
229+
bundle_identifier=bundle_id
216230
)
217231
except Exception as e:
218232
return InspectorResponse(
@@ -372,7 +386,7 @@ def capture_ios_ui_dump(device_udid: str):
372386
pass
373387

374388
# No real source available
375-
raise Exception("iOS service error. Please reload the iOS inspector page or run a test case.")
389+
raise Exception("iOS service error. Make sure simulator is running.")
376390

377391

378392
async def upload_android_ui_dump():

test_ios_detection.py

Lines changed: 0 additions & 125 deletions
This file was deleted.

test_ios_hierarchy.py

Lines changed: 0 additions & 155 deletions
This file was deleted.

test_ios_server.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

test_ios_upload.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)