Fires a custom event.QTP-fireevent

Syntax –

Behavior.fireEvent(sEvent[, oEvent])

Example –

The following partial script component is derived from a calculator script component sample. Whenever the result changes, the script component fires a custom onResultChange event back to the page, passing the result as an expando property of the event object.

  1. <component>
  2. <public>
  3. <event name="onResultChange" />
  4. </public>
  5.  
  6. <implements type="Behavior">
  7. <attach event="onclick" handler="doCalc");
  8. </implements>
  9.  
  10. <script language="JScript">
  11. <![CDATA[
  12. function doCalc(){
  13. // Code here to perform calculation. Results are placed into
  14. // the variable sResult.
  15.  
  16. oEvent = createObjectEvent();
  17. oEvent.result = sResult;
  18. fireEvent("onResultChange",oEvent);
  19. }
  20. ]]>
  21. </script>
  22. </component>