How to use Javascript custom step for Test Cases?

The QAS now provides an ability to add Javascript custom steps to Test Cases recorded through Test Recorder. The steps can be added in javascript and async javascript code format.

To use the javascript code in your Test Case

  • Create a new Test Step

  • Select the ‘Execute Java Script’ action in the commands column.

  • Provide your Javascript code in the Input column, refer screenshot attached.

  • For Async javascript code, the user has to select ‘Execute Async Java script’ command.

Here is the example of the codes for reference:

  • Javascript code:

    • window.scrollBy(0,60000) history.go(0) window.open("URL")

       

  • Async Javascript code:

    • window.setTimeout(arguments[arguments.length − 1], 800);

 

Furthermore, users can extract the Test Case to code and obtain the code in the .bdd file with the javascript custom steps.