How to escape special symbols for sending to RPA

rpa

#1

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

<script><![CDATA[
  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;
  }
]]></script>

#2

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


#3

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


#4

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