I need to execute an anonymous function within another function without actually calling the parent function, as it will lead to errors.
Here is the parent function:
function onloadCallback() {
grecaptcha.render("recaptchaHolder", {
"size": "invisible",
"sitekey": "1Lcsvh53yhsd5312hhsg554dfhs098bbeyi_Hv",
"callback": function(resp) {
$("zendesk-ticketing-form").attr("grecaptcha", resp)
}
});
}
The function I want to call is:
function(resp){$("zendesk-ticketing-form").attr("grecaptcha",resp)}
I am working with Java Selenium for this task.
I attempted the following:
js.executeScript("onloadCallback()(\"" + responseToken + "\")");
but this results in an error because it calls onloadCallback (the parent function) before accessing the internal anonymous function.
Any suggestions on how to achieve this?