How to simulate BT and WiFi connection during UI automation test with fastlane?

130 Views Asked by At

I am beginner of iOS testing and I really need help. Thank you in advance. I've tried to implement a simple test with fastlane to create screenshots and evaluate if all needed elements exist (fastlane snapshot, I follow most common tutorials and up to now everything works fine). App which is tested needs a WiFi and Bluetooth connection to open some tabs. I have no idea how to manage it. When app is redirected to view where connection is checked and test wait (methods such as sleep(30) or waitForExists(app.otherElements["snapshotReady"], waitSeconds: 60) but nothing happens and app cannot be loaded to the next view (generally, when app works on device context is switched to the next view). I could not find any programatically method anywhere to manage it.

1

There are 1 best solutions below

0
On

The best way to do this to look for the FASTLANE_SNAPSHOT key in the UserDefaults that is inserted automatically by snapshot.

if UserDefaults.standard.bool(forKey: "FASTLANE_SNAPSHOT") {
    // runtime check that we are in snapshot mode
}

You can use logic like this to simulate any user interfaces that you may need.

More info can be found at - https://docs.fastlane.tools/actions/snapshot/#launch-arguments