Click on button in form not working


#1

I am trying to setup a crawler that logs in to a website.
My code fills out the username and password in the form correctly, but I cannot get it to click on the submit button. I’ve tried several versions of .submit() and .click(), but nothing seems to happen.

HTML source:

Crawler code (not working):
$(‘input.button’).click();

Any suggestions?


#2

Hi @Historisk_Dragter,

You probably need to wait a little after you click on button. But it depends on website. If it is SPA it should work but, if there is any redirect, crawler will try to add redirected page to queue. You can see what happens in log.

Anyway there are better way how you can log into website:

  1. Copy cookies from browse - https://kb.apify.com/authentication/log-in-to-website-by-transferring-cookies-from-web-browser
  2. Use Apify actor, which is more generic solution for creating web crawler - There is one example how you can log into website using the actor. - https://kb.apify.com/actor/how-to-log-in-to-a-website-using-puppeteer