'Execute a JS on webView chrome console

I want to execute a Js code on webView console without using the tools icon, I have tried that code:

btnGo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String js = "var images = $$('img');\n" +
                    "for (each in images) {\n" +
                    "console.log(images[1].src);\n" +
                    "}";
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
                webView.evaluateJavascript(js, null);
            } else {
                webView.loadUrl("javascript:(function(){" + js + "})()");
            }
        }
    });

but I am getting:

I/chromium: [INFO:CONSOLE(1)] "Uncaught ReferenceError: $$ is not defined", source: https://website.com/page1 (1)

Image explain: Screenshot



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source