绕过Appium Server 直接与 UIA2/WDA 交互的技巧
要绕过Appium Server直接与UIA2/WDA进行交互,可以使用以下步骤:\n\n1. 安装Appium和相关驱动:首先需要安装Appium和相应的驱动,以便能够使用UIA2或WDA。这些驱动可以通过Appium的命令行工具或通过命令行安装。\n\n2. 启动UIA2/WDA服务:启动UIA2或WDA服务,以便Appium可以连接到它们。根据所使用的服务,您可以执行类似于以下命令:\n\n - 对于UIA2:xcrun xcodebuild test-without-building -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'platform=iOS Simulator,name=<device_name>'\n\n - 对于WDA:xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'platform=iOS Simulator,name=<device_name>' test\n\n 上述命令中的<device_name>应替换为您要运行测试的设备的名称。\n\n3. 连接到UIA2/WDA:使用Appium的remote功能,将Appium连接到UIA2或WDA。您可以使用类似于以下代码的Python代码来实现:\n\n python\n from appium import webdriver\n\n desired_caps = {\n 'platformName': 'iOS',\n 'automationName': 'XCUITest',\n 'deviceName': '<device_name>',\n 'udid': '<device_udid>',\n 'bundleId': '<app_bundle_id>',\n 'xcodeOrgId': '<team_id>',\n 'xcodeSigningId': 'iPhone Developer'\n }\n\n driver = webdriver.Remote('http:\/\/localhost:4723\/wd\/hub', desired_caps)\n \n\n 上述代码中的<device_name>、<device_udid>、<app_bundle_id>和<team_id>应替换为相应的值。\n\n4. 与UIA2/WDA交互:现在,您可以使用Appium提供的API与UIA2或WDA进行交互。例如,您可以使用以下代码来查找元素并执行操作:\n\n python\n element = driver.find_element_by_name('Button')\n element.click()\n \n\n 上述代码将查找名称为'Button'的元素,并执行点击操作。\n\n这样,您就可以绕过Appium Server直接与UIA2或WDA进行交互。请注意,UIA2和WDA都是苹果的自动化框架,因此您需要确保在设备上安装了相关的依赖项和配置。
原文地址: https://www.cveoy.top/t/topic/p0QB 著作权归作者所有。请勿转载和采集!