Hi! I’m trying to paste rich formatted text into a form field in a browser. I’ve created the formatted text successfully by using the “Create HTML Content” activity and saving it as a variable. However, when using the “Type Into” activity, it pastes the actual code rather than the formatted text. I’ve also played with the Chromium and Simulate input methods and I’m still having issues. I appreciate the help in advance!
Did you check how is looking the string value before using it into the Type Into?
Maybe, indeed, is not formatted as you think.
There’s no way to “type” rich text format text into the text field (neither manually nor with RPA).
The workaround is to send it first to the clipboard and then paste it into the text field/area using send Ctrl+V.
You can use code from the following link with the Invoke Code activity: .net - How to set HTML to clipboard in C#? - Stack Overflow
Note that you need to provide headers to get it interpreted as formatted text in the clipboard.
“Version:0.9
StartHTML:000xxx
EndHTML:000xxx
StartFragment:000xxx
EndFragment:000xxx”
The Startxx and Endxx values need to be calculated dynamically.
Hi @M_Mahoney
Instead, you can use the “Inject JS Script” activity to inject JavaScript code that manipulates the DOM and sets the innerHTML of the desired form field.
- Create HTML Content:
- Navigate to the Web Page
- Inject JS Script
// Assuming ‘formattedText’ is the variable holding your HTML content
var formattedText = ‘
Your formatted text goes here
’;document.getElementById(‘yourFormFieldId’).innerHTML = formattedText;
- Since injecting JavaScript might take some time to execute, ensure you have adequate delay or waiting activities (like “Wait For Ready” or “Delay”) after the script execution
Hope this helps
Welcome to the community
Manually how do you do that cna you please explain?
Also if manually youa re doing then click on text after formatted and select inspect element and check how the text is displayed in the html
Cheers
Thanks, everyone! Sending it to the clipboard ended up being the simplest solution for my use case. For context, it’s rich text formatting with headings and paragraphs similar to what you see in emails. I used a “Get from Clipboard” before Ctrl+V as well which perhaps isn’t completely necessary.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.