> For the complete documentation index, see [llms.txt](https://docs.does.qa/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.does.qa/guides/test-mfa-login.md).

# Test MFA login

Many apps ask for a one-time code after the password. DoesQA can generate that code from a saved MFA secret and type it into the page, so the Flow can finish sign-in without a phone.

```mermaid
flowchart TD
  open["Open login"] --> creds["Set value username and password"]
  creds --> submit["Touch submit"]
  submit --> mfa["Set MFA"]
  mfa --> finish["Touch MFA submit"]
  finish --> check["Check text"]
```

Use the **Flow Builder** for this walkthrough.

## What you need

* A website URL with MFA on login
* Username and password [Values](/values/value-store.md)
* The MFA secret for that account (the same secret you would scan into an authenticator app)

## Save the MFA secret

{% stepper %}
{% step %}

## Open MFA settings

Go to [**Settings → MFA**](/configuration/mfa.md).
{% endstep %}

{% step %}

## Create an MFA entry

Choose **Create**, set a **Title**, and paste the **MFA Secret**.

Confirm the live code against your authenticator app, then save. You will not be able to view or edit the secret again after it is saved.
{% endstep %}
{% endstepper %}

## Build the login Flow

{% stepper %}
{% step %}

## Open the sign-in page

Start with [**Open**](/test-steps/starter/open.md). Point it at your login URL.

<figure><img src="https://app.does.qa/screenshots/node/starter_open.png" alt="Open Test Step"><figcaption><p>Open</p></figcaption></figure>
{% endstep %}

{% step %}

## Enter username and password

Add [**Set value**](/test-steps/action/set-value.md) for the username and password fields. Use Values from the [Value Store](/values/value-store.md).

<figure><img src="https://app.does.qa/screenshots/node/action_input_setValue.png" alt="Set value Test Step"><figcaption><p>Set value</p></figcaption></figure>

Add [**Touch**](/test-steps/action/touch.md) on the control that submits the password step.

<figure><img src="https://app.does.qa/screenshots/node/action_touch_single.png" alt="Touch Test Step"><figcaption><p>Touch</p></figcaption></figure>
{% endstep %}

{% step %}

## Wait for the MFA field

When the code field appears, add a [**Wait**](/test-steps/runner/wait-for-element-to-be-displayed.md) or [**Check**](/test-steps/check/check-displayed.md) if your app needs a moment to show it.
{% endstep %}

{% step %}

## Enter the MFA code

Add [**Set MFA**](/test-steps/action/set-mfa.md).

<figure><img src="https://app.does.qa/screenshots/node/action_input_setMFA.png" alt="Set MFA Test Step"><figcaption><p>Set MFA</p></figcaption></figure>

1. Set **Mode** to **Saved**.
2. Choose the **MFA Key** you created under Settings.
3. Choose the **Element** for the code input.

DoesQA generates a fresh time-based code and types it into that Element.
{% endstep %}

{% step %}

## Finish sign-in

Add [**Touch**](/test-steps/action/touch.md) on the control that submits the MFA step.

Add [**Check text**](/test-steps/check/check-text.md) or another Check that proves the session landed where you expect.

<figure><img src="https://app.does.qa/screenshots/node/check_text.png" alt="Check text Test Step"><figcaption><p>Check text</p></figcaption></figure>
{% endstep %}
{% endstepper %}

{% hint style="info" %}
**Pro tip:** After the login works, save it as a [Step Group](/better-coverage/reuse-steps-with-step-groups.md) so other Flows can reuse the same MFA path.
{% endhint %}

## The finished Flow

![Open through Check text for an MFA login Flow](/files/nnXmqAN8QoLoXL75j2Ez)

## Mode: Saved or New

| Mode      | Use it when                                                                 |
| --------- | --------------------------------------------------------------------------- |
| **Saved** | The secret lives under [Settings → MFA](/configuration/mfa.md) (usual path) |
| **New**   | You need to pass a secret only for this step                                |

Prefer **Saved** so secrets stay in one place and Flows stay easy to share.

## Related

* [MFA](/configuration/mfa.md)
* [Set MFA](/test-steps/action/set-mfa.md)
* [Reuse steps with Step Groups](/better-coverage/reuse-steps-with-step-groups.md)
* [Reuse a login session](/guides/reuse-a-login-session.md)
* [Set Value](/test-steps/action/set-value.md)
* [Touch](/test-steps/action/touch.md)
* [Value Store](/values/value-store.md)
