Skip to content

clearKeychain ​

Clear iOS keychain data for the app under test.

Partial support in Astra Scout

iOS Simulator only. On a real iPhone the command fails, because the keychain is sandboxed and cannot be reset from the host; use clearState to reinstall the app instead. The step is not available on Android.

The clearKeychain command clears all data from the iOS Keychain.

WARNING

This command only applies to the iOS Simulator.

Syntax ​

The command takes no arguments.

yaml
- clearKeychain

Why use this command? ​

The iOS Keychain is a secure storage container used by apps to persist login credentials, tokens, and other sensitive information.

In automated testing, the Keychain can become a source of state leakage, where a previous test run leaves a user logged in, causing subsequent tests to fail or behave unexpectedly. Using clearKeychain ensures your app starts from a clean, default state.

Automate Keychain clearing ​

If you want to clear the Keychain every time the app starts without adding a separate command, you can use the clearKeychain parameter directly within the launchApp command:

yaml
- launchApp:
    clearKeychain: true

You can use Hooks to automate Keychain clearing across all your tests.