Page 1 of 1

Setting Element Value with Javascript Not working on a webpa

PostPosted: Sun Jul 05, 2020 12:55 pm
by sanjosetour
Hi guys
Im working with Cefsharp to automate a form submission of a web page: https://ahrefs.com/user/login

I'm trying to set the email and password with Javascript, but it auto clears out as if it were not set when I click on submit:
Code: Select all
email = document.querySelector('input[name=email]');
email.value = "testing@example.com";

I have tried even doing with an event, but still no success.
Code: Select all
event = new Event('change', { bubbles: true });
email.dispatchEvent(event);

What can be the solution?

Re: Setting Element Value with Javascript Not working on a w

PostPosted: Sun Jul 05, 2020 6:08 pm
by magreenblatt
Does it work in Google Chrome?

Re: Setting Element Value with Javascript Not working on a w

PostPosted: Sun Jul 05, 2020 10:55 pm
by sanjosetour
nope, it doesnt as well

Re: Setting Element Value with Javascript Not working on a w

PostPosted: Mon Jul 06, 2020 9:35 am
by magreenblatt
Then it is not supported. You can research if something similar is possible using the DevTools protocol.

Re: Setting Element Value with Javascript Not working on a w

PostPosted: Mon Jul 06, 2020 3:26 pm
by amaitland
The website likely has validation to prevent bots. Either execute some JavaScript to remove the validation or use a different input method.

You can try something like https://stackoverflow.com/questions/596 ... mmatically