1

How to automate tests which requires OKTA OTP verification?

Use case:

  1. User will the internet banking website
  2. User will enter valid ID and password
  3. Website will request for an OTP
  4. User receives an OTP on mobile phone
  5. User enters the OTP
  6. Login successful

I will be using an automation framework to automate this use case. How do I automatically retrieve the OKTA OTP and automate step 3 & 4?

Is there any plugin / Tool / Utility which will allow me to read the OTP via API's or by any other means?

I will be using TOSCA or maybe Selenium to automate this use case.

James Z
  • 12,209
  • 10
  • 24
  • 44

1 Answers1

0

Though till the time this is still some area which does not have much progress in automation side like Captcha/Barcode/OTP. But you can explore the following options:

  1. OKTA API: Check if OKTA provides an API that allows you to programmatically retrieve the OTP.

  2. Mobile Phone Emulator: Use a mobile phone emulator or simulator, such as Appium, to automate the interaction with the mobile phone. With Appium, you can simulate the receipt of the OTP and extract it programmatically within your automation framework.

  3. Mock OTP Generation: If retrieving the real OTP is not possible or challenging in your testing environment, you can create a mock OTP generation mechanism specifically for automation testing. This could involve generating and storing a unique OTP value within your test environment that can be used during the automation process.

Regarding the choice of automation frameworks, both TOSCA and Selenium can handle these tasks.

  • I like option number 3 - Can you please tell me how to create Mock OTP Generation. Do I need to request developer or system admin to do something for us to Mock OTP Generation ? Please let me know as I haven't done this before. what are the steps involved to get this done. – Charlotte Ryerr Jun 14 '23 at 05:32
  • Determine the specific requirements of the OTP generation mechanism for your testing environment considering factors such as OTP length, allowed characters, expiration time, and any other relevant constraints and create a method around that to generate a random one and also verify with your developer if this can be integrated with and gets automated. – Samira Kumar Nanda Jun 14 '23 at 08:12
  • HI Samira, I am a bit confused about your latest comment. Yes I can write a method to generate a random OTP. But can you please tell me, what are the steps that are needed to create a mock server ? what will dev have to do to create a mockserver ? – Charlotte Ryerr Jun 19 '23 at 22:08
  • Install the chosen mock server framework/library and initialize a new mock server instance that fits your programming language and development stack like WireMock, JSON Server, MirageJS, and Nock. This involves configuring the server's hostname, port, and any other required settings. Define all the API routes and handlers that your mock server. Integrate this with your application. – Samira Kumar Nanda Jun 21 '23 at 08:14