extract otp from email

How can we extract the email OTP ?

could you specify the scenarios with detail steps?

Similar problem I am also facing so describing below:

  1. Login to gmail in chrome browser able to do with Katalon
  2. Click on recent email or from subjet or from sender. Not ablt to do?
    Not able to do because every time getting error element not found.
  3. Read the OTP from mail. Not able to do and How to do this?
  4. Store the OTP in excel so that can read while doing the mobile app validation
    regards
    Satish Kumar Pal

hi all,
i have the same need : getting content of OTP gmail.
I get an error while Using gmail plugging (https://store.katalon.com/product/39/Read-and-Write-Gmail-Messages-Keywords) : “No signature of method: java.lang.Boolean.call()”

Any solution ?
Tks in advance.

hello,

if you are able to print out email content then will use regex to extract OTP from string

def testString = "Treat this as confidential. 869256 is your login OTP. Sharing it with anyone gives them full access to your Paytm Wallet. Paytm never calls to verify your OTP."

        //will match any 6 digit number in the message
        Pattern p = Pattern.compile("(|^)\\d{6}");
        		
        if(testString!=null){
        	 Matcher m = p.matcher(testString);
        	 if(m.find()) {
        		 println(m.group(0));
        	 }
           else
           {
        	   println("no match");
           }
        }

Please watch you tube video and capture the object so that you can click on it.

https://www.youtube.com/watch?v=33uDYlnBgLc

Hallo @Timo_Kuisma1,

I follow your code, but regex not filtering tag html.
please check my code below, what’s wrong in my code?

def messageList =[]
for(int i=0; i<folder.getMessageCount(); i++){
if(folder.messages[i].getSubject().equals(“Reset Password Request”))
println folder.messages[i].getContent()
messageList.add(folder.messages[i])
}
//=============================================

def otpMessage = messageList[messageList.size()-1].getContent()
def otpCode = otpMessage
	Pattern p = Pattern.compile("/(?<=<strong>)(.*?)(?=</strong>)/g");
	
	if(otpMessage!=null){
		Matcher m = p.matcher(otpMessage);
		if(m.find()){
			println(m.group(0));
		}else{
		println("no match");
	}
	}

hi,

not sure what you are looking for, give more code
or otpMessage content