Browser Java script outcome variable

  • 13 March 2024
  • 3 replies


i am using browser javascript package for getting values from website..The script is running fine it is printing data in console but i want the return value in outcome variablel of automation anywhere..i have tried return value in function then also it didint work...i have set the outcome variable but it didnt work..can anybody know how to get output of javascript in the outcome variable??plz help

3 replies

Userlevel 5
Badge +11

Hi @Alfa001 ,

Please try with below sample code

function extractDataFromPage() {
    var data = document.getElementById('someElementId').innerText;
    return data;

  1. Execute JavaScript in Web Page command to run the script.
  2. Use "Assign" command to store the returned value in an A360 variable.

Even I'm facing same issue can you take live website extract a single value and share us the code and website url @Tamil Arasu10 

@Aaron.Gleason Any help

Userlevel 3
Badge +5

In the Browser: Run JavaScript action, use the following format for returning a value:

//call the function (must be first)

//define the function
function getTitle() {
return document.title;

Notice I am calling the function before it is defined. If you call it after, it will fail.

In this case, this simple function returns the title of the web page. You can have it return other values as well. Note that multiple values will have -1, -2, -3, etc., appended to the variable name. $myVariable$ will be the first value, $myVariable-1$ will be the second, etc.