BeanShell assertion unable hold data in array
2 posters
Page 1 of 1
BeanShell assertion unable hold data in array
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
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
Re: BeanShell assertion unable hold data in array
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:
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.
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
Beanshell assession
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
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
Beansheel convert string to array
thanks for the solution.
I fixed the error in my code and add try /catch block as suggested.
I fixed the error in my code and add try /catch block as suggested.
sreekanth_n- Posts : 3
Join date : 2014-06-19
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|