I have a C# Winform app using CefSharp that logs into a website. The site changed the login screen and now when I set the value of the elements for the userid and password, they are not retained in the element properties.
I have tried setting both the defaultValue and value properties of the elements, but when the code executes the "click" the values disappear from the input fields and the login fails.
//Enable the login button
chromeBrowser.ExecuteScriptAsync("document.getElementsByTagName('BUTTON')[0].disabled='false';");
//Set the userID on the login form
chromeBrowser.ExecuteScriptAsync("document.getElementsByClassName('form-control__formControl___3uDUX')[1].defaultValue=" + '\'' + userID + '\'');
chromeBrowser.ExecuteScriptAsync("document.getElementsByClassName('form-control__formControl___3uDUX')[1].value=" + '\'' + userID + '\'');
//Set the password on the login form
chromeBrowser.ExecuteScriptAsync("document.getElementsByClassName('form-control__formControl___3uDUX')[2].defaultValue=" + '\'' + passWord + '\'');
chromeBrowser.ExecuteScriptAsync("document.getElementsByClassName('form-control__formControl___3uDUX')[2].value=" + '\'' + passWord + '\'');
//Click the login button
chromeBrowser.ExecuteScriptAsync("document.getElementsByTagName('BUTTON')[0].[0].click();");
I've noticed through keying in the values directly on the page that the userid and password are passed to a react event
__reactEventHandlers$41017fwaadp:
autoFocus: true
className: "form-control__formControl___3uDUX"
data-automation-id: "uname"
disabled: false
maxLength: undefined
onBlur: ƒ ()
onChange: ƒ ()
onFocus: ƒ ()
onKeyPress: ƒ ()
onKeyUp: ƒ ()
onPaste: ƒ ()
placeholder: undefined
readOnly: false
type: "text"
value: ""
Setting the values through code fails to pass the value.