JMeter Beanshell assertion

This article is used to record the problems encountered in writing beanshell assertions.

Question 1: JSONObject not found in namespace

Process: Write the code under beanshell as follows:

1 String response_data = prev.getResponseDataAsString();

2 JSONObject data_obj = new JSONObject(response_data);
3
4 String current_page = data_obj.get("data").get("current_page").toString();
5 log.info("The current page:"+current_page)

Error: Typed variable declaration: Class: JSONObject not found in namespace

The content of the error report is very clear. No JSONObject was found in the namespace. But I am using it, and I must report an error.

Solution: Click to download the jar package and put it into the jmeter installation directory/lib/ext. Then write in beanshell: import org.json.*; Just quote it

1 String response_data = prev.getResponseDataAsString();

2 JSONObject data_obj = new JSONObject(response_data);
3
4 String current_page = data_obj.get("data").get("current_page").toString();
5 log.info("The current page:"+current_page)

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5490 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.