- I tried to register into an account
Gave creds–>Clicked on Continue button–>It generated a Dynamic 4 digit OTP
- Switched the tab and opened a url to hit an API which generates the OTP in the below fashion.
- From this Tab2, I need to copy each number every time and switch the tab to Tab1. Paste the copied number i.e., 4 _ _ _
- Switch to Tab2 copy the next number i.e., 7 -->Switch to Tab1 paste the number in the 2nd place i.e., 4 7 _ _
Similarly for remaining two ,copy and paste the numbers by switching between the tabs
Hurdle is OTP is dynamic.
Any suggestions on this issue? Should I store the response some where everytime or is there any better approach for this issue.
When you say copy, can I assume you can grab the contents into a String? Then instead of paste, you then setText(), or concatenate, the String value you grabbed. Or does it actually have to be copy & paste? If the latter, then look into Robot commands.
OTP i got from a API
I need to grab a number out of 4 digit Dynamic OTP
for ex OTP is 1 2 3 4
I will grab 1 and pass it in a web browser application
Again I need to grab the next number which is 2 and pass it in the previous page web application
Similarly I will pass 3 and 4
So have you tried to grab the whole OTP and then have to parse (or substring()) the OTP into different pages of the web app.
Is the One Time Password a 4 digit reference? Can you get the OTP as one grab. If you can, then you should be able to use OTP.substring(startingRef, startingRef + 1) as the part to “paste”. Sorry, maybe I am not seeing the true situation. Note the starting position of your OTP would be zero, not one.
Just a note that if the OTP is an Integer, then you may have to use:
OTP.toString().substring(startingRef, startingRef + 1);