How to escape special symbols for sending to RPA



When we needed send password to RPA, we should escape special symbols.
This sample function how to do it.

  import org.openqa.selenium.remote.*;
  import org.openqa.selenium.*;
  import org.apache.commons.lang3.StringEscapeUtils;
  public String escaped(String text, RemoteWebDriver driver) {
    String res = text;
    String brName = driver.getCapabilities().getBrowserName();
    if ("autoit".equals(brName)) {
      res = res.replaceAll("([\\{\\}\\!\\#\\^\\+]+)","{$1}");
    } else {
      res = StringEscapeUtils.escapeJava(res);
    return res;


Do I need to do escaping in case of Chrome and Firefox?


Yes, it will be correct for Chrome and FireFox too.
I fixed function.


How do I use this with the universal driver? How do I get a reference to driver object when scripting?