JMeter : Load/Performance Test Tool
Would you like to react to this message? Create an account in a few clicks or log in to continue.

BeanShell assertion unable hold data in array

2 posters

Go down

BeanShell assertion unable hold data in array Empty BeanShell assertion unable hold data in array

Post  sreekanth_n Thu Jun 19, 2014 4:17 pm

i am using Jmeter for functional testing
i have expected value in CSV
one of the value in CSV has set of sub-strings which need to be validated against web page response

Lets say CSV column contains Type;Price
I need to check whether the response contains Type and Price.

I am planning to get the value into an array and loop array to check the value in page response.

Though i written JS code, BeanShell assertion is throwing exception.

can you pl provide quick solution.

regards
sree


sreekanth_n

Posts : 3
Join date : 2014-06-19

Back to top Go down

BeanShell assertion unable hold data in array Empty Re: BeanShell assertion unable hold data in array

Post  glinius Thu Jun 19, 2014 10:38 pm

Hi Sree.

Beanshell is more like to Java than to JavaScript.

There is not enough information in your request to provide full help, however as a clue you can wrap your beanshell code into try/catch block as follows:

Code:
try{
// do something
}
catch (Exception ex){
log.error("Something went wrong", ex);
}

and inspect jmeter.log for more-or-less readable error cause.

Also it worth checking How to use BeanShell: JMeter's favorite built-in component guide for more advice and a kind of Beanshell cookbook.

glinius

Posts : 6
Join date : 2013-10-23

Back to top Go down

BeanShell assertion unable hold data in array Empty Beanshell assession

Post  sreekanth_n Fri Jun 20, 2014 9:33 am

I am successfully able to implement Beanshell assertion for other conditions and is working.

As per your suggestion, I have written code in java and is still not working

String body= new String(ResponseData);

// get data from csv
String filters = vars.get("filter_types");
String[] filter_list = filters.split(";");

// check whether filters associated to select sub-category
for (filter_type = 0; filter_type  < filter_list.length; filter_type++)
{
String brand_name = filter_list[filter_types];

// search along with tag name to avoid duplication only by text - <figcaption>Brand</figcaption>
String brandname = "<figcaption>" + brand_name +"</figcaption>";  

if(!body.contains(brandname))
{
Failure=true ;
FailureMessage = page_name + " - Page contains does not contain brand " + brand_name;
print (page_name + " - Page contains does not contain brand " + brand_name);
log.warn(page_name + " - Page contains does not contain brand " + brand_name);
}
}

Error displayed -


Assertion failure message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``String filters = vars.get("filter_types"); String[] filter_list = filters.split( . . . '' : Typed variable declaration : Arrays may only be indexed by integer types.: Primitive not a number

sreekanth_n

Posts : 3
Join date : 2014-06-19

Back to top Go down

BeanShell assertion unable hold data in array Empty Beansheel convert string to array

Post  sreekanth_n Fri Jun 20, 2014 12:22 pm

thanks for the solution.

I fixed the error in my code and add try /catch block as suggested.

sreekanth_n

Posts : 3
Join date : 2014-06-19

Back to top Go down

BeanShell assertion unable hold data in array Empty Re: BeanShell assertion unable hold data in array

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum