I've been experimenting with automating logins using JavaScript code. My current process involves inspecting the elements of the username box, password box, and login button. I then simply use the "copy selector" feature to find the selector and adjust my .js file accordingly.
This approach worked like a charm on LinkedIn: URL:
const USERNAME_SELECTOR = '#username';
const PASSWORD_SELECTOR = '#password';
const CTA_SELECTOR = '#app__container > main > div:nth-child(2) > form > div.login__form_action_container > button';
However, when trying the same method on other websites, I encountered issues with finding the login/submit button (CTA_SELECTOR).
For instance: URL:
const USERNAME_SELECTOR = '#si_username';
const PASSWORD_SELECTOR = '#si_password';
const CTA_SELECTOR = '#si_box > form > div:nth-child(4) > div > button';
Running this script resulted in an error indicating that it couldn't locate the CTA_SELECTOR on the page.
Does anyone have any suggestions on how to ensure I obtain the correct selector?