ios appium做自动测试,怎样能够获取设备的出口IP

ios appium做自动测试,想要通过appium工具,获取ios设备的出口IP,不是局域网IP
一种可能想到的方式是通过appium打开ios上的浏览器,在页面发送一个查询IP的请求,但这个方法不够灵活,不能够满足多样化的需求
有没有其他的办法可以做到

您可以使用 Appium 的 get_settings() 方法来获取 iOS 设备的网络信息,其中包括其出口 IP 地址。

以下是一个 Python 代码示例:


from appium import webdriver

desired_caps = {
    'platformName': 'iOS',
    'platformVersion': '14.4',
    'deviceName': 'Your device name',
    'udid': 'Your device UDID',
    'automationName': 'XCUITest',
    'bundleId': 'your.app.bundle.id',
    'noReset': True
}

driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

settings = driver.get_settings()
ip_address = settings['network']['interfaces'][1]['ipv4']['address']

print("设备的出口 IP 地址是:", ip_address)



driver.quit()

连接iOS设备到电脑,并使用Xcode工具或者Appium工具连接到设备。

在Python中使用Appium Python客户端与设备进行通信。

  • 这篇博客: appium、环境配置、并发测试中的 Appium并发综合测试实践 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • 并发测试我自己是这么理解,分配相应的端口,检测端口是否被占用,构建appium进程组,