Home > Enterprise >  Simulating Key Press On DOM element
Simulating Key Press On DOM element

Time:09-28

I am trying to automate a web entry form with C# using WebView2.

Web entry form has three DOM Elements: Input (UserName/Password) and Entry Button (disabled).

If you enter value to input areas by keyboard (manually) Entry Button is enabled. But sending Java Scripts to set value of input boxes do not make this button enabled. Of course it is a guard to disable automation of this page...

Is there a way to make Entry Button enabled with java script?

Page image is below:

Form Entry

CodePudding user response:

It seems that site owner has arranged actions for 'Entry Button' will be enabled only by keystroke. Guard against automation...

To simulate keystroke action you may use below code for each DOM element:

document.getElementById('USERNAME').focus();
document.execCommand('insertText', false, 'YourName');
document.getElementById('PASSWORD').focus();
document.execCommand('insertText', false, 'Password');
document.getElementById('ENTRY').click();

This will activate 'Entry Button' by pasting your data like keystrokes...

  • Related