Forum Discussion

_lauren11's avatar
Occasional Contributor
4 years ago

How to access the verification code sent on email in soap ui open source

I am using SoapUI open source. Through automation, I want to access the email by doing login(lets say, i have stored email id and password in two different variables), and get the verification code using groovy script in SoapUI open source

The email i shall be receiving will be from "" and the content of the message will be in the format:--

"Your verification code is 126222."   




Thanks in advance

  • _lauren11 :


    Yes it will work surely i have also did this on my end to get OTP from gmail.


7 Replies

  • _lauren11 :


    If it is coming into response and you need to extract OTP then you can use below code to extract OTP from the String.


    String str = "Your verification code is 126222.";
    str = str.split(" ")[str.split(" ").length-1];
    char[] charArray = str.toCharArray();
    int charSize = charArray.length; ("String is : "+str);
    StringBuilder sBuild = new StringBuilder();
    for(int i=0;i<charSize;i++) {
    	if( Pattern.matches( "\\d", String.valueOf(charArray[i]) ) )
    } (sBuild.toString());
    • _lauren11's avatar
      Occasional Contributor

      HimanshuTayal Sir, that's great approach if i already have response from email in my script. But, I am sorry. I want to get this response from email directly. I do not have response already with me. I need to know, how to access it from email and password i store in variables


      Thanks in advance

      • HimanshuTayal's avatar
        Community Hero

        _lauren11 : You mean you need to access browser and open particular Email and then access this OTP?


        If this is the question then you need to integrate Selenium with soapui.


        Let me know in case you need help on selenium.