I ran into the same problem. After a long cleaning of the Internet, I came to the conclusion that this cannot be done using the UIAutomation class. You need to either do this manually, or use a different method, for example, write an objective-c code fragment that programmatically disables wifi / network or uses some other automation tool to write a script that turns on / off the network. Then you can run / call the script / code from the tools using the performTaskWithPathArgumentsTimeout function. Although I could not realize it myself. If anyone has a better solution, please share!
source share