Setting Element Value with Javascript Not working on a webpa

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Setting Element Value with Javascript Not working on a webpa

Postby sanjosetour » Sun Jul 05, 2020 12:55 pm

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?
sanjosetour
Newbie
 
Posts: 2
Joined: Sun Jul 05, 2020 12:53 pm

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

Postby magreenblatt » Sun Jul 05, 2020 6:08 pm

Does it work in Google Chrome?
magreenblatt
Site Admin
 
Posts: 10462
Joined: Fri May 29, 2009 6:57 pm

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

Postby sanjosetour » Sun Jul 05, 2020 10:55 pm

nope, it doesnt as well
sanjosetour
Newbie
 
Posts: 2
Joined: Sun Jul 05, 2020 12:53 pm

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

Postby magreenblatt » Mon Jul 06, 2020 9:35 am

Then it is not supported. You can research if something similar is possible using the DevTools protocol.
magreenblatt
Site Admin
 
Posts: 10462
Joined: Fri May 29, 2009 6:57 pm

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

Postby amaitland » Mon Jul 06, 2020 3:26 pm

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
Maintainer of the CefSharp project.
amaitland
Master
 
Posts: 788
Joined: Wed Jan 14, 2015 2:35 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 32 guests