I am using jmeter version 5.2.1. For loading my javascript file I am using jsr223 sampler with language as javascript. My problem is that I have to login on cognito from jmeter without using external phantomjs driver. So I have imported the cognito javascript files that are used for login on cognito and provided the correct details. Previously this code was working correctly when I was login using phantom js through external created js files. But on moving my code in jsr223 sampler it is giving error "AWSCognito" is not defined in . I have also increased the size of jsr223 sampler to 600 i.e jsr223.compiled_scripts_cache_size=600
I am executing the following code
load("D:/apache-jmeter-5.2.1/bin/aws-cognito-sdk.min.js");
load("D:/apache-jmeter-5.2.1/bin/amazon-cognito-identity.min.js");
//var CognitoUserPool = AmazonCognitoIdentity.CognitoUserPool;
var userData = { user_email: '[email protected]', user_pw: 'test', UserPoolId: 'test', ClientId: 'test',}
var authenticationData = {
Username : userData.user_email,
Password : userData.user_pw,
};
var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
var poolData = {
UserPoolId : userData.UserPoolId,
ClientId : userData.ClientId
};
var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool(poolData);
var userData = {
Username : userData.user_email,
Pool : userPool
};
var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
// console.log('access token + ' + result.getAccessToken().getJwtToken());
//document.getElementById("successAndErrorMessages").innerHTML=result.getAccessToken().getJwtToken();
log.info(result.getAccessToken().getJwtToken());
},
onFailure: function(err) {
log.info(err);
},
});
on executing my script I got the following error
2020-01-02 10:47:59,037 INFO o.a.j.t.ThreadGroup: Started thread group number 1
2020-01-02 10:47:59,038 INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started
2020-01-02 10:47:59,039 INFO o.a.j.t.JMeterThread: Thread started: AutomationR&D 1-1
2020-01-02 10:48:00,381 ERROR o.a.j.p.j.s.JSR223Sampler: Problem in JSR223 script JSR223 Sampler (load js)path, message: javax.script.ScriptException: ReferenceError: "AWSCognito" is not defined in <eval> at line number 15
javax.script.ScriptException: ReferenceError: "AWSCognito" is not defined in <eval> at line number 15
at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:454) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155) ~[nashorn.jar:?]
at javax.script.AbstractScriptEngine.eval(Unknown Source) ~[?:1.8.0_221]
at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:225) ~[ApacheJMeter_core.jar:5.2.1]
at org.apache.jmeter.protocol.java.sampler.JSR223Sampler.sample(JSR223Sampler.java:71) [ApacheJMeter_java.jar:5.2.1]
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:627) [ApacheJMeter_core.jar:5.2.1]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:551) [ApacheJMeter_core.jar:5.2.1]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:490) [ApacheJMeter_core.jar:5.2.1]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257) [ApacheJMeter_core.jar:5.2.1]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_221]
Caused by: jdk.nashorn.internal.runtime.ECMAException: ReferenceError: "AWSCognito" is not defined
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291) ~[nashorn.jar:?]
at jdk.nashorn.internal.objects.Global.__noSuchProperty__(Global.java:1442) ~[nashorn.jar:?]
at jdk.nashorn.internal.scripts.Script$1312$\^eval\_.:program(<eval>:15) ~[?:?]
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:449) ~[nashorn.jar:?]
... 11 more
Please help me in resolving this issue