I'm trying to automate a login with some javascript code. My process at the moment is inspecting element of each the username box, password box and login button. I then simple use "copy selector" to find the selector and adjust my .js file accordingly.
This worked perfectly well on linkedin for example: URL: https://www.linkedin.com/login?fromSignIn=true&trk=guest_homepage-basic_nav-header-signin
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, using the same method on some other sites does not work with the login/submit button (CTA_SELECTOR).
For example: URL: https://www.criticker.com/signin.php
const USERNAME_SELECTOR = '#si_username';
const PASSWORD_SELECTOR = '#si_password';
const CTA_SELECTOR = '#si_box > form > div:nth-child(4) > div > button';
Running this will tell me it cannot find the CTA_SELECTOR on the page.
Does anyone know what I can do to ensure I do get the correct selector?