JohanTS
(Johan van de Venter)
5 May 2020 08:39
1
The test case that I need to build is a signup test case with the signup after you enter your email they send you an OTP pin to the email and I need to copy that OTP and put it in to complete the signup process but that OTP pin is also available on the page in a hidden input elements value how can I get that value and then put that value in the correct input field
Here is the OTP input field and the hidden input field is at the bottom with the value inside
René
(René)
5 May 2020 09:14
2
Hi,
This should be possible with
Get Element Attribute
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Get%20Element%20Attribute
Or maybe with
Get Value
https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Get%20Value
But if it is hidded, it may be that Selenium can not access it. Then you could use Java Script.
JohanTS
(Johan van de Venter)
5 May 2020 09:38
3
Hi,
Thanks for the replay do you maybe have a example where you get the value from the element and store it in a variable to use later?
René
(René)
5 May 2020 09:59
4
${code}= Get Element Attribute //input[@name="six_digit_random_number"] value
Log To Console ${code}
This should work.
The content of the attribute “value” is stored in the variable ${code}.
@JohanTS OTP also can be copied from Email using IMAP library and can be put it into required field
JohanTS
(Johan van de Venter)
7 May 2020 06:14
6
I have seen the Imap library But am struggling to get it to copy the value and paste it in the correct field
I have handled it… I can share you the code
Open Mailbox server=smtp.gmail.com user=xxxx@gmail.com password=xxxx
${LATEST}= Wait For Email fromEmail=xxxxx@gmail.com toEmail=xxxxx@gmail.com subject=xxxxx
${parts} = Get Email Body ${LATEST}
@{words} = Split String ${parts}
Input Text css=input[name="otp"] ${words}[39]
1 Like
@JohanTS code worked for you
JohanTS
(Johan van de Venter)
13 May 2020 12:13
10
I just get this error backElement with locator ‘//input[@name=“six_digit_random_number”]’ not found.
JohanTS
(Johan van de Venter)
13 May 2020 12:14
11
This can work but at the moment We are testing with random emails and then just get the otp from a hidden field
But with a real mail message this works thank you
Hi @nagarajhebbar can help me also with that code im working also with email otp and I’m stock on it. Can you provide a sample video on how to integrate? Thanks a lot
I can provide the code if you need it please let me know and share me the emailaddresss
Hi @nagarajhebbar here it is ryeloie13@gmail.com Thank you so much.