public static String GetId(string role, string name) { string id = ERROR_IDENTIFICATION_FAILED; try { // NOTE: role should be a number (according to ACC), but this is not always the case // e.g. Firefox (3.6.8) returns html tags such as "div", "pre", "h4", ... // note: an empty name is not very useful here because it would result in id only e.g. "42-" for all unnamed text fields // note: double check required to handle names that use special characters only, e.g. buttons with names "<" and ">" if (!String.IsNullOrEmpty(name)) { name = BaseUtils.sanitizeString(name); } if (!String.IsNullOrEmpty(name)) { id = BaseUtils.sanitizeString(role + "-" + name); } } catch (Exception) { } return(id); }