2 Factor Authentication

Hi all,

I need to create a test case for a login process, in our testing environment the 2 factor authentication code is displayed in a noted feedback box as text.

How do I get that text into the “Enter Code Here” text box?

See below image

Kind Regards

We will need to see the html for this element so we can assist you further

So im able to get the code, how do I enter the code into the “Enter Code Here” text field?



WebUI.setText(findTestObject(‘Object Repository/Page_MobiLife - Main - Account Management/input_Login to_c1’), ‘Alex’)

WebUI.setEncryptedText(findTestObject(‘Object Repository/Page_MobiLife - Main - Account Management/input_Login to_c2’),

WebUI.click(findTestObject(‘Page_MobiLife - Main - Account Management/Page_MobiLife - Main - Account Management/button_Login’))

WebUI.waitForElementVisible(findTestObject(‘Page_MobiLife - Main - Account Management/span_Debug (Non-production env) 2FA Code 932052’),

String extractInt = WebUI.getText(findTestObject(‘Page_MobiLife - Main - Account Management/span_Debug (Non-production env) 2FA Code 932052’)).substring(37, 42)

println extractInt

I have figured it out.

String extractInt = WebUI.getText(findTestObject('Page_MobiLife - Main - Account Management/span_Debug (Non-production env) 2FA Code 932052')).substring(37, 43) 

WebUI.setText(findTestObject(‘Object Repository/Page_MobiLife - Main - Account Management/EnterAuthCode’), extractInt )

1 Like

i’ve got a similar project i’m working on - wondering if your two-factor codes are dynamic in your devlab?