FormFill entry and firing events

In a few cases, while filling in a form, the Recorder does not properly fire the necessary events to allow the website to know the form field has been filled in. You'll generally notice this during playback when you can see the field filled in, but when the form is submitted an error message appears on the screen: "This is a required field".

This code helps solve this problem, by manually filling in the value of the form field, and then manually firing the needed event.

The example fires the blur event. Another common event that may need to be fired, depending on how the site was coded, is the change event.

formField = document.getElementById("FormElement_customer_emailAddress_nav-your_info_YI02");
formField.value = "t@t.com";

function fireEvent(element,event){
	var evt = document.createEvent("HTMLEvents");
	evt.initEvent(event, true, true ); // event type,bubbling,cancelable
	return !element.dispatchEvent(evt);
}

fireEvent(formField, "blur");