AnsweredAssumed Answered

unable to compare variable values in java script step

Question asked by Raj_JP on Mar 16, 2018
Latest reply on Mar 17, 2018 by Joel Nesmith

Steps:
====
#1. add a JavaScript object and place the following code

 

testExec.setStateValue("ExpectedID","123");

 

testExec.setStateValue("ExpectedESIGN","false");

 

#2. save the below json in notepad in c drive
{
    "eSign": false,
    "id": "123"
}
#3. Add Read a File(Disk,URL or Classpath) Step (continuation with #1) and browser the above file path
   - save as RESPONSEJSON

 

#4.  Add Java Script Step and add following code:

 


import java.io.*;
import java.util.*;
import java.lang.*;
import java.lang.Integer;

 

strActualID = testExec.getStateValue("ActualID");
strExpectedID = testExec.getStateValue("ExpectedESIGN");

 

strActualESIGN = testExec.getStateValue("ActualESIGN");
strExpectedESIGN =  testExec.getStateValue("ExpectedID");
 

 

if(!strExpectedESIGN.equals(strActualESIGN)){
     testExec.setStateValue("Result","Failed");
  }
else{
     testExec.setStateValue("Result","Passed");
  }
  
if(!strActualID.equals(strExpectedID)){
     testExec.setStateValue("Result1","Failed");
  }
else{
     testExec.setStateValue("Result1","Passed");
  }

 


#5. Add a Output log Message step: and se the following:
ActualID = {{ActualID}}
ActualESIGN = {{ActualESIGN}}

 

Expected esign = {{ExpectedESIGN}}
Expected Id = {{ExpectedID}}

 


  {{Result}}

 
  {{Result1}}

 

#6. Run the script, see that {{Result}} & {{Result1}} displays as Failed.

 

instead of Passed.
Can you [please me how to solve this..

 


the output displays as
ActualID = 123
ActualESIGN = false

 

 

 

 

 

Expected esign = false
Expected Id = 123
  Failed

 

  Failed

Outcomes