def generateJS(tag, atr, evalString):
    """ Generates js string for web element searching. """
    js = """
    function find_by_tag_and_attr(tag, atr, evalString) {
        const elements = document.getElementsByTagName(tag);
        const arrayLength = elements.length;
        const results = [];
        for (let i = 0; i < arrayLength; i++) {
            if (elements[i].getAttribute(atr) == evalString) {
                results.push(elements[i])
            }
        }
        return results;
    }
    return find_by_tag_and_attr(tag="%s", atr="%s", evalString="%s");
    """ % (tag, atr, evalString)
    return js