iOS UI 自动化 : toggle network settings during test execution time from within the tests

标签 ios networking automation disconnect

我需要测试网络在测试流程的各个点断开连接时发出的各种警报。所以我需要断开 iPad/模拟器的网络连接。有没有什么方法可以让我们在测试执行期间从测试中切换网络设置?

我搜索了一下,发现不可能:Is it possible to disable the network in iOS Simulator? 但是,这里的回复已经过时了,想知道我们现在有什么办法吗?

最佳答案

UIAHost上使用函数performTaskWithPathArgumentsTimeout,您可以运行计算机上的任何程序(如果您知道绝对路径)。

如果您可以编写一个程序或脚本(例如使用 osascript)来关闭您的互联网连接,那么这是可能的。

我实际上使用此函数在模拟器中打开一个网页,该网页重定向到我的应用程序处理的链接,从而测试从浏览器打开应用程序时的行为。

关于iOS UI 自动化 : toggle network settings during test execution time from within the tests,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14219708/

相关文章:

ios - SKA行动向前推进

testing - 元素内的偏移量无法滚动到 View : (0, 0): http://localhost/groupc/edit/378

python - pywinauto 类型键不起作用

python - python 的 recvfrom() 队列数据包吗?

ubuntu - Docker容器访问本地DNS

c - 段错误 11 - 网络程序

vb.net - 如果我在 win7 上编译 VB6 应用程序,ADODB.Connection 错误为 "Class does not support Automation or does not support expected interface"

iphone - 在iphone中以编程方式将两个图像合并到一个图像上

ios - DTAssetProviderService 无法使用模拟器启动 DTXConnection - mac os sierra

ios - Swift:如何根据当天的当前时间显示两个图像之一