问题
I want to automate how ios App behave while running the XCUITest. When manually executing the test, I turn off the wi fi adapter. How do I do that using Xcode UI test?
thanks
p.s. I found that we can use below command to disable wi fi. But to do this I will need to send my app to background. I need to do this without sending current app to background.
let settingsApp = XCUIApplication(bundleIdentifier: "com.apple.Preferences")
settingsApp.launch()
settingsApp.tables.cells["Airplane Mode"].tap()
回答1:
You can re-activate your app afterwards with the new activate() method on XCUIApplication. It will resume your app without restarting it.
let app = XCUIApplication()
app.launch()
let settingsApp = XCUIApplication(bundleIdentifier: "com.apple.Preferences")
settingsApp.launch()
settingsApp.tables.cells["Airplane Mode"].tap()
// Relaunch app without restarting it
app.activate()
来源:https://stackoverflow.com/questions/46404535/xcuitest-how-to-disable-wi-fi-while-app-is-running