Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to access variables into "Execute Javascript"

Options
rvmseng
rvmseng Posts: 89

Hi support team,

How can I access to variables into "Execute Javascript" ? please refer to attached file.

Comments

  • rvmseng
    rvmseng Posts: 89
    Options

    Dear support team,

    would you please assist me.

  • tony
    tony Posts: 25 ✭✭
    Options

    Code in the Execute Javascript action is run directly in the browser in exactly the same way as the Selenium JavascriptExecutor.executeScript function. Because it is run in the browser it has no visibility into other programs, including SOAtest. So, you cannot reference SOAtest variables from within this code.

    If you wish to create a generic function, the closest you could do would be to create a JavaScript file with your generic function and then add other functions that called it with specific values, such as:

    function setText(element, text) { element.value = text; }
    function setHelloWorld(element) { setText("hello world"); }
    

    In SOAtest you would then use the "File" radio button, choose your JavaScript file, and reference the "setHelloWorld" function.