How to search for text and replace it in HTML

I have multiple html elements in an email template hosted on squarespace. My current automation is able to login, navigate to the template, duplicate it and begin applying customizations. However, the template contains text sections that are not readily obtainable by an id or other indicator since replication regenerates the embedded ids, if there are any. I need a way to double-click the text, which is not supported in Chrome or Firefox, and replace it with my custom text. It should be that simple, but the double-click is not supported. Unfortunately, the templates do not render in IE either. Can anyone supply some helop for this issue?

1 Like

do you have any option to use the Ctrl+H and replace the text in it?

Ctrl+H goes to History in Chrome and in Firefox. So, even if I can do that, it doesn’t do what you are expecting, I believe.

If you can replace the entire text, then my initial thought would be to Get the text and store in a variable. Then, use .Replace() to change certain words, so no click actions needed. Finally, just clear the rendered text and place in your new text.

1 Like

ClaytonM, Do you happen to have an example of how to do that. I am pretty new at this. I am currently trying to use the Inject JS Script Activity to find the text in the HTML body and replace it with the new text.

Sorry, I don’t have a solution readily to show extracting the html text and am unsure off the top of my head. I was thinking you could use the Get Text or Get Attribute activity, but it sounds like it might be more complicated than that.

After you get the text stored into a variable, you can use .Replace()

Assign activity: newtext = existingtext.ToString.Replace("word1","newword1").Replace("word2","newword2")


I guess the thing that really bothers me with this is that the double-click text activity does not work. If that worked and there was a way to do a string replace from that, then that would be awesome. Any ideas on that?

Thanks. This helped me also after much searching on the internet, this worked!