I've been attempting to log in to the Udemy site using JavaScript, but I'm having trouble triggering the click action on the "log in" link. Unfortunately, the .click()
method doesn't seem to be working when I try to select the element. The login modal only opens up after I manually click the link, and since .click()
isn't functioning properly, I can't automate the login process as desired.
var id = document.getElementById("id_email");
var password = document.getElementById("id_password");
var submit = document.getElementById("submit-id-submit");
id.value = "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2971717171694e44484045074a4644">[email protected]</a>";
password.value="XXXXX";
submit.click();
The provided script works for me, but only if I manually click the Login link before executing it. I'm still trying to figure out how to trigger the click event on the login button to fully automate the login process.
I'm currently stuck on how to initiate the click on this particular element.
document.getElementsByTagName("require-auth")[0].querySelectorAll("a");
Even though the element is being selected, attempting to use click()
on it results in the following error:
VM2907:1 Uncaught TypeError: document.getElementsByTagName(...)[0].querySelectorAll(...).click is not a function(…)