This post will help you automate the microsoft azure page authentication page with MFA enabled OTP option.
First thing we need to enable the MFA option from the security page .
Navigate to Security page
Turn on the two-step verification
I’m using google authenticator App to generate the OTP .You can try any App of your choice.
In the following page , by default you will see a QR code . Instead click on “I can’t see the bar code” option which will give you the security key.
Copy and place the secret key on your framework properties file or as per your framework convenience.
Now to use this Secret key and generate the OTP, we need a Jar library. Add this dependency to you maven file.
<dependency> <groupid>org.jboss.aerogear</groupid> <artifactid>aerogear-otp-java</artifactid> <version>1.0.0</version> </dependency>
After you add this dependency , generate the code and pass it to the textbox using selenium.Totp is the class that takes the secret key as parameter and generate the OTP required.String azurescretKey = readYourSecretKeyFromPropertiesFile; Totp generatedOTP = new Totp(azurescretKey) driver.findElement(your_locator).sendKeys(generatedOTP)