Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
We don't have a way to export this macro.

Retrieve OTP Code and make it available for your GDSL test manually. When you launch a measurement on a Test Bench device with the Greenspector CLI, you can receive a the OTP via an email or a SMS on your own device linked to your account. May be you have to use an authenticator to retrieve the OTP manually.

To transmit the OTP code manually to the GDSL test, you have two following options.

Use a disposable email with mailsac

We use the same mechanism as describe in the two parts : “Create and configure a mailsac account” and “Example with OTP” of the page Authentication with email but the difference is that you have to send manually an email containing the OTP you have to the mailsac email.

Use a public JSON File

Get the OTP and write it to a public json file on Internet that your GDSL test will read.

...

Here is an example of a GDSL test reading the OTP code you have set in your json file. You have to adapt to your own context :

Code Block
#authEnterStoredData# this method checks your json file exists with an empty value before asking a new OTP code
initOTPManualauthInitManualJSONFileOTP,https://myonlineotpfile.json

# Log into your app, for example a login / password form with a submit button
# you have to adapt to your own context
setTextById,mylogin,com.myapp:id/loginEditText
setTextById,mypassword,com.myapp:id/passwordEditText
waitUntilTextBeforeClick,submit

# At this time an OTP code should be sent by email or sms.
# this method waits for a value to be available on the previous file during 10 minutes
# When you have received your code, set the OTP code on the previous file
waitAndStoreOTPauthWaitAndStoreData

# Select the edit text of your app where to put OTP Code
# for example
clickByText,OTP code

# Then you can use this method to enter the OTP code in the edit text
enterStoredOTPauthEnterStoredData

How to add a json file on Internet containing an OTP Code

You can use any drive or system specific to your company. The key is to have an online json file that can be accessed through an unique URL and that you can modify at any time.

...

Note

If you used the same file to read OTP code, you can have the following GDSL error :
"Error on line initOTPManualauthInitManualJSONFileOTP,https://drive.google.com/uc?export=download&id=1AzN-6sC0oFr0EZb8-2k6bOUR8rIcbbbr0-W (line: 22). Cause: The test could not access the json file (HTTP error 403). If you use google drive, the access may be blocked by google. Please try to create and use another one"
In this case
If you have these error, please do not create a new file with the same name, you need to create a file with another name. This is a google protection.