How to access variables into "Execute Javascript"

rvmsengrvmseng Posts: 79

Hi support team,

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

Comments

  • rvmsengrvmseng Posts: 79

    Dear support team,

    would you please assist me.

  • tonytony Posts: 18

    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.

Sign In or Register to comment.