Need help splitting a stored text

Hello, I am trying to extract a verification code from a email. What im doing right now is storing the full email then trying to split it up. When i try to split it up i get this error “undefined”

Here is a example of the email:

Hi Sdfgdsfs,

Welcome to Randomname! Please enter the code below to continue with your RandomName account application:

Email Verification Code: 001115

Please note the code will expire in 30 minutes.

Please contact our customer service team if you have any questions.

Sincerely,

Random Name.

I just need to extract and store the:001115

This is what i have right now in my code:

{
“Name”: “test”,
“CreationDate”: “2020-4-24”,
“Commands”: [
{
“Command”: “storeText”,
“Target”: “xpath=/html/body/main/div[1]/div/div[2]/div[2]/div/div[1]/div/div[2]/div[3]/pre”,
“Value”: “t”
},
{
“Command”: “storeEval”,
“Target”: "s1 = “{t}\"; r = s1.split (\":"); var s2 = r[1]; s2", "Value": "t" }, { "Command": "echo", "Target": "the extracted test is: {t}”,
“Value”: “blue”
},
{.

When running this i get the undefined error rather then the verification code. Can someone please help me out?

Better use ExecuteScript_Sandbox instead of the outdated storeEval. See here:

The problem is not the split that is very easy but is detect the frame inside the email.

Every email use a different frame and some types of frame are very hard to detect.

I tryed to record, it detect frame name but when i run macro report error in frame name.

Split is not the problem , you can multi split to cut the part of text you need.

@chronicdr

I solved the problem with my suggestion storetext i add image, now you have 6 digits stored in variable and you can type it in any site.

Working like a charm :slight_smile:

Macro Code

{
  "Name": "Extract_Code_Email",
  "CreationDate": "2020-4-25",
  "Commands": [
    {
      "Command": "store",
      "Target": "true",
      "Value": "!ERRORIGNORE"
    },
    {
      "Command": "bringBrowserToForeground",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=/html/body/main/div[1]/div/div[2]/div[2]/div/div[1]/div/div[2]/div[3]/pre",
      "Value": "TextExtracted"
    },
    {
      "Command": "echo",
      "Target": "${TextExtracted}",
      "Value": "#shownotification"
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return ${TextExtracted}.split(\"Email Verification Code: \")[1];",
      "Value": "TextExtracted"
    },
    {
      "Command": "echo",
      "Target": "${TextExtracted}",
      "Value": "#shownotification"
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return ${TextExtracted}.split(\"Please note the code will expire in 30 minutes.\")[0];",
      "Value": "TextExtracted"
    },
    {
      "Command": "echo",
      "Target": "${TextExtracted}",
      "Value": "#shownotification"
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return ${TextExtracted}.replace(/\\D/g,\"\");",
      "Value": "TextExtracted"
    },
    {
      "Command": "echo",
      "Target": "${TextExtracted}",
      "Value": "#shownotification"
    }
  ]
}

Image