I am trying to get username from webview. It returns null object.
webView.settings.javaScriptEnabled = true
webView.evaluateJavascript(
"(function() { return document.getElementsByClassName('lgn-loginname') })();",
ValueCallback<String> { s ->
// 's' contains the result of the JavaScript evaluation
Log.d("JavaScript Result", "Result: $s")
}
)
Also with this it is null.
webView.evaluateJavascript(
“(function() { var elements = document.getElementsByClassName(‘lgn-loginname’); ” +
“return elements.length > 0 ? elements[0].innerHTML })();”,
ValueCallback { s ->
// ‘s’ contains the result of the JavaScript evaluation
Log.d(“JavaScript Result”, “Result: $s”)
}
)
I tried many things and always getting null. What am I doing wrong?