Is there a way to copy+paste from email to a form?

So this is essentially what I’m trying to do:

  • Visit site
  • Click a button
  • Email arrives with code
  • Copy code within email
  • Paste into field on site
  • Click button

I have it all set up but can’t figure out how to go about copying the code within the email and pasting in the field. The email is the exact same format every time, but obviously a new email is sent with a new code for each. Any ideas?

Btw email I’m just using a browser based client (protonmail), which I’ll already be logged in with.

One idea I had was to run 2 separate scripts, one for copying the code in the email, storing in CSV, and then running another script to use the code in the CSV to paste into the field. Am I over complicating things with this?

To get the text from the email I recommend:

  • XClick (set focus on the email)
  • XType | ${KEY_CTRL+KEY_A}
  • XType | ${KEY_CTRL+KEY_V}

=> now the value is in !clipboard

See also Desktop automation-number harvesting from desktop screen - #2 by admin and Desktop Automation - OCR Latest Entry In A List - #2 by Plankton

1 Like

Thanks for that - let me try it out.

What are your thoughts on whether to create 2 separate scripts or somehow use a single one? Is there a way to switch between tabs in the same script?

So every time I try to use !clipboard it keeps copying the xpath target:

    {
  "Command": "XClick",
  "Target": "xpath=//*[@id=\"message0\"]/div[2]/div[3]/div/table[2]/tbody/tr/td/table/tbody/tr[5]/td/div/table/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr/th/table/tbody/tr/td/div/span/strong",
  "Value": ""
},
{
  "Command": "XType",
  "Target": "${KEY_CTRL+KEY_A}",
  "Value": ""
},
{
  "Command": "XType",
  "Target": "${KEY_CTRL+KEY_V}",
  "Value": ""
}

Would this be correct? Sorry, kinda new to UI.vision and I can’t seem to find an example for this. The text I’m copying isn’t in a cell, just plain text on the page. Also the path portion I put in target does highlight the text it seems, just don’t know what to do from there to copy it. Thanks in advance.

This is a long work and need more steps

Need login in email, refresh email in box, open exact email you need, select part of code and copy and paste it in another page

Yes, I know. I have the rest of the code. I just need help with this one part.

Strange… can you record a video that shows the problem?

And/or: Try using an image instead of XPath.

Yeah I can - is the code I copied here supposed to work? And what do you mean by use an image exactly? To focus on? What I did was used auto mode to click the wanted area, and then just copied over that path to the click command.

Edit: I managed to get it to focus on the email, however when it does CTRL+A, it highlights everything on the page rather than just that one line. Also where in the code would I actually copy the text?

This work can be done with standard selenium command, no need Xtype and XClick

I would like to bump this old thread…I have the same issue. How can this be solved? Was this ever resolved? @Sourc3code

What is the standard selenium command to read an email and find the value? @newuserkantu I am also struggling with the OCR screen scraping - and I don’t think it is necessary since this is just text in an email. @ulrich

Assume all the other issues are solved - e.g. I have the correct email pulled in a browser tab. Just need to know how to copy and paste the verification code and ignore all the rest of the text.

The format is:

Your verification code is: 123456 (it is always 6 numbers, but random every time)

Some text here

Some more text here

Last line of text here

{
      "Command": "sourceExtract",
      "Target": "regex=Your verification code is: [0-9]{6}",
      "Value": "Code",
      "Description": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return ${Code}.replace('Your verification code is: ','');",
      "Value": "Code",
      "Description": ""
    },
    {
      "Command": "prompt",
      "Target": "${Code}",
      "Value": "",
      "Description": ""
    }
2 Likes

Thanks so much for this @uiuser. This is very helpful. I am still having some difficulty because the web service I am using seems to have a 3 panel frame layout - i.e on the left there are the folder names, then the middle is all the emails, and the right side the open email. I have gotten to the stage where I have the email selected and open, but I can’t get sourceextract to work as the main page’s html doesn’t contain that content. Any tips?

try adding frame number

I’ve tried adding selectFrame | index=1 or 0,1,2,3, etc and it still doesn’t pick it up. Any other suggestions? The other option I can try is OCRExtract I guess?

try relative=top
record click and see if there is frame

relative=top doesn’t work either, this is when I recorded a click on the email window, I get:
xpath=//*[@id=“zm_centerHolder”]/div/div/div/div[3]/div/div[2]/div/div/div[2]/div/div/div[2]/div/div

I’m not sure if it is a frame or a different type of element, but when I navigate to my main browser’s source code, I can’t see the text of the email

EDIT: I seem to be able to get it to work with OCRExtract, but it is definitely slower than the regex sourceExtract finder you suggested, but it does the job. Not sure how else I can try to troubleshoot the sourceExtract to get it to work?

Thanks so much for the help with the regex code though you shared earlier, it really helped with the OCRExtract. I’m having a separate problem with OCRExtract only working online mode and not local, but I have created a separate thread for that.

difficult to solve without access to webpage
Extract all text of the TAG
then use javascript to get required data

1 Like

@uiuser how would I exact all the text from the TAG if I can’t find the frame using selectFrame? can I DM you email credentials or I can post a demo account here? I imagine it should be relatively straight forward to use sourceExtract to get the text, but I am not sure what I am missing

you can message me
you can message me