Replace or Escape special characters in aaname reference to target link to click on

I’m trying to scrape a list of new articles. My routine works except when the link includes special character (such as “&”, or “,”)

The way I am targeting the link to click on is to using the aaname of the element using row(“Column1”).ToString which I’ve scraped into a table in a previous step. How do I fix this so that the robot can target the correct aaname?

Basically, if I’m passing in “Acme & Beta announce joint venture” into this element, what do I need to replace “&” with? Is it just an escape character?

[current line of code]:
```"<webctrl aaname='"+row("Column1").ToString+"' parentid='main-container' tag='A' />"

Try replacing & and , with their html codes and see if that works.

For example & with &amp;

Thanks! Even more rookie question by how do I do a replace? I tried using

[example:] replace(row(“Column1”).ToString,“&”,“&amp”) but that doesn’t seem to be the correct syntax

row(“Column1”).ToString.Replace("&","&amp;")

Thank you!

For those playing along, I did the replace as noted using .replace (you can also do additional replaces with .replace(x,y).replace(a,b) etc… , yay), then passed the string below into an element so I could target an aaname

[]: # strrrow = row("Column1").ToString.replace("&,"&amp;")

then

[]: # "<html app='chrome.exe' omit:title='name of the page' />"+"<webctrl aaname='"+strrow+"' parentid='main-container' tag='A' />"

there’s probably a better way, but this worked for me!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.