class ElementFinder implements Finder {

    public static String exitCondition(String findTag) {
        int pos = findTag.indexOf('}');
        if (pos == -1) {
            return "e.tagName == '" + findTag.toUpperCase() + "'";
        }
        int caretPos = findTag.indexOf('^');        
        boolean contains = caretPos != -1 && caretPos < pos;
        if (!contains) {
            caretPos = 0;
        }
        String tagName = StringUtils.trimToNull(findTag.substring(caretPos + 1, pos));
        String suffix = tagName == null ? "" : " && e.tagName == '" + tagName.toUpperCase() + "'";
        String findText = findTag.substring(pos + 1);        
        if (contains) {
            return "e.textContent.trim().includes('" + findText + "')" + suffix;
        } else {
            return "e.textContent.trim() == '" + findText + "'" + suffix;
        }
    }

    public  ElementFinder(Driver driver, String fromLocator, Type type);

}