Text Checks Why you need to be really smart

21 Jan

Most of the load testing tools available in the market provides the facility to insert the text checks and verify that you have indeed got the right response for your request from the server.To some extent,by default added text checks works quite comfortably in the scripts.Most tools have setting which tells the scripter to enable the text checks while recording.Million dollars effort saved.

However as the technology is getting more and more aware of user experience behavior,the default mechanism of inserting the text checks by the load testing tools is failing to catch with growth of technology.No one really wants to expose the nasty messages that comes with HTTP 500 or Application crash and also its not consider the best practice of software development.

Lets take an example of LoadRunner and analyze as why scripter needs to pretty smart enough to identify as what content he needs to add from the server response and why he needs to add that particular content as the text check.

Let us first point out as what options does LoadRunner provide to insert the text check in our scripts.For this post, we will taking the web protocol for analyzing.LoadRunner provides at least 4 ways to ensure to that  response we get meets our expectation.

Web_reg_find. This function has to be placed before the request which needs to be validated for right response.Web Reg Find has got lot of attributes which can help us to find the right text.It is basically a service function of LR.This functions scans the entire server response to check if the required text is present or not.It can also be inserted while recording the business flow with LoadRunner.

Web Global Verification : This function is similar to web reg find function with only difference that it searches the text in every subsequent response received for each request.If the text is found, then required action is taken.It is global in scope and applies for entire script.

Content Checks : LoadRunner provides the mechanism for validating the response for right content.Content checks can be enabled from the run time setting of the LoadRunner scripts.Once enabled and when script is ran, setting are directly loaded along with script in the LG’s ram.This speeds up the execution time of the script.

Correlation Functions : Web reg save functions can also be used for text checks in certain cases.

All these above 4 methods for inserting check texts are done via Load testing tool LoadRunner and if used correctly they can help us to identify that we are getting the right response for the request.

Now let us consider the some cases where using these 4 methods fails to detect any issues with scripts.

Now lets say that I have a login form with 2 fields and 2 buttons in it.Lets say the HTML code for Login form will normally look something like below

<html>
<head>
<title>
Test Login Form
</title>
<script type=”text/javascript”>

function validatelogin()
{

if(document.getElementById(‘usernameuid’).value.length==0)

alert(“Error:UserId can’t be blank”);

else if(document.getElementById(‘passwordpwd’).value.length==0)

alert(“Error:Password can’t be blank”);

return false;

else

{

alert(“Successfully logged in”);

window.open(“Welcome.html”);

}

}

</script>
</head>
<body>
Enter UserId : <input type=”text” id=”usernameuid”><br/>
Enter Password: <input type=”text” id=”passwordpwd”><br /><br/>
<input type=”button”value=”Login”onclick=”validatelogin()”/>
<input type=”button”value=”Cancel”/>
</body>
</html>

Now in the above html code, we have some validation rules for Username and Password field,now if for some reason during the load test if we are unable to send the username data to the application(This frequently happens in large tests with large loads for various reasons), then we will be getting message as ” Error:UserId can’t be blank“from the application.Oops LoadRunner catches this message and halts the execution of the iteration for that user since we have set this message as text check or contents check.However there is a drawback to this method.Most frequently people set the such kind of error messages as text checks/Content checks in their scripts.

If you look deeply in this code, you will understand that this piece of code comes back every time when request containing this code is hit.These are all client side error messages and should not be used as “Text Checks or Content checks” for your application with any of the functions that comes with the tool.

Now lets have a look at the title tag of the above code, when recording this particular page, LoadRunner will insert the text check for title of this page,now assuming that I have an error in the response,some application by design do not allow the page to move forward unless fields are filled correctly, under such circumstances,manually focus remains on the page and still we have page with title as”Test Login Form”.Load testing tools in such a circumstances considers this as pass and moves on to the next request line.See load testing tools always work with request and response pattern.Another area where load testing tools are lacking behind terribly.Load testing Scripts lacks real user focus behavior.

Moral of the story: Never ever use text string as text checks which comes as a part of the client functions or client side code for any of the web application.Text strings used as check points should be unique and this should and must originate from the server side communication.

Please  note that code above has to taken from internet and edited to meet my requirements.I recommend the performance engineer should at least be able to read and judge what a piece of CSS,HTML and JavaScript code does even if he is not able to code it.This helps a lot and saves many man days of effort.

Technorati Tags: ,
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: