Hi All
Thanks to Zee Gao (高楼) some of my posts are now translated into Chinese language on 7dtest.com forum. Here are the links:
Web Services performance using LoadRunner HTTP Vuser script – http://www.7dtest.com/bbs/thread-3483-1-1.html
Don’t waste your time – http://www.7dtest.com/bbs/thread-3481-1-1.html
Cleaning browser cache – http://www.7dtest.com/bbs/thread-3482-1-1.html
HTTP POST or GET – http://www.7dtest.com/bbs/thread-3480-1-1.html
Thanks Zee & 7dtest.com users!
Uncategorized
Some of you may already know Selenium. Basically it’s free and open source tool for web application functional testing. It’s mainly know as replacement for HP’s QuickTestProfessional. I’ve recently discovered Selenium as very helpful for automating data setup for load testing.
Here is a small description howto setup Eclipse and run Selenium script through it.
1) Download Eclipse IDE from http://www.eclipse.org/downloads/
2) Download Selenium RC from http://seleniumhq.org/download/
3) Download Junit from http://www.junit.org/
4) Create new project in Eclipse:
- Go to File -> New -> Java Project
- enter project name e.g. “Sample”
- Click “Finish” button
5) Import Selenium and JUnit packages into the project:
- In Package Explorer right click project “Sample” and select Properties
- Go to “Java Build Path” then select “Libraries” tab
- Click “Add External JARs” and import junit-4.7.jar and selenium-java-client-driver.jar
Now our Eclipse environment should be ready. Next step is to prepare a test case in Selenium IDE. I’ve prepared small test that searches for “linux” word in google. To export test case as Java, in Selenium IDE go to Options -> Format -> Java (Junit) Selenium RC. As a result you should get something like this:
-
package com.example.tests;
-
-
import com.thoughtworks.selenium.*;
-
import java.util.regex.Pattern;
-
-
public class Untitled extends SeleneseTestCase {
-
-
setUp("http://change-this-to-the-site-you-are-testing/", "*chrome");
-
}
-
public void testUntitled
() throws Exception {
-
selenium.open("/");
-
selenium.type("q", "linux");
-
selenium.click("btnG");
-
}
-
}
Default Junit code generated by Selenium doesn’t use Selenium RC. Because of that I updated the code a little bit to connect to localhost Selenium RC on port 4444. Here is updated version:
-
package com.example.tests;
-
-
import com.thoughtworks.selenium.*;
-
import java.util.regex.Pattern;
-
-
public class Untitled extends SeleneseTestCase {
-
public DefaultSelenium selenium;
-
-
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.com/");
-
selenium.start();
-
}
-
public void testUntitled
() throws Exception {
-
selenium.open("/");
-
selenium.type("q", "linux");
-
selenium.click("btnG");
-
}
-
}
Now, lets add it in our Eclipse project:
- In Package Explorer right click on our “Sample” project and select New -> Class
- Enter class name “Untitled” and package name “com.example.tests”
- Click “Finish” button
Before we run our test, we need to start Selenium RC. For that open command line and under selenium-remote-control-1.0.1/selenium-server-1.0.1 run command “java -jar selenium-server.jar”. It will run Selenium RC server on default port 4444.
Now, to start the test just select Run -> Run As -> Junit test. It should open two IE browsers. One for Selenium RC and second with Google results for “linux” word.
Because we run Java code, it’s only up to us how we want to run the test. Below is our example update to search for “linux” word in a loop 5 times with 5 seconds intervals.
-
package com.example.tests;
-
-
import com.thoughtworks.selenium.*;
-
import java.util.regex.Pattern;
-
-
public class Untitled extends SeleneseTestCase {
-
public DefaultSelenium selenium;
-
-
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.com/");
-
selenium.start();
-
}
-
public void testUntitled
() throws Exception {
-
for(int i = 0; i < 5; i++)
-
{
-
selenium.open("/");
-
selenium.type("q", "linux");
-
selenium.click("btnG");
-
selenium.waitForPageToLoad("10000");
-
-
}
-
-
}
-
}
General
eclipse, selenium
Correct me if I’m from but I always thought that for particular transaction there should be only ONE average response time. But it looks like it’s not the case in LR Analysis.
I recently discovered that by changing granularity on average transaction response time graph, Analysis also recalculates average times under the graph. In my understanding granularity is responsible only for making the graph easier to read and thats all it should do. But by changing granularity we are also changing how many points LR actually counts which results in different average response times for different granularity.
So shame that this is not mentioned in the manual. Of course according to HP support it is mentioned there and this is a feature, not a bug
So my tip for today: be careful when looking at response times on average transaction response graph. Use “Summary” page if you want to omit any mistakes.
LoadRunner
analysis, granularity, response time
Web (HTTP/HTML) scripts in LoadRunner are implemented using C programming language. And like always with C, you should remember about some basics. One of them is that few string handling function can return NULL value instead of correct pointer which will definitely lead to exception like the one below:
-
Action.c(7): Error: C interpreter run time error: Action.c (7): Error — memory violation : Exception ACCESS_VIOLATION received.
Basically if you see message like this, it is not any internal LoadRunner error. It means that you made a mistake in your script and you need to fix it. But let’s start from the beginning with some example:
-
Action()
-
{
-
char * x_p;
-
-
lr_save_string("hello_world!", "MESSAGE");
-
x_p = (char *)strchr(lr_eval_string("{MESSAGE}"), ‘ ‘);
-
lr_save_string(x_p, "MESSAGE_FROM_SP");
-
lr_output_message(lr_eval_string("{MESSAGE_FROM_SP}"));
-
-
return 0;
-
}
This small piece of code takes parameter MESSAGE with value “hello_world”, then search for the first space character and display the string starting from that place up to the end. Function strchr() is responsible for searches for the space character. If it’s found then strchr() will return a valid pointer (something like 0xb36ac56e). But if the space is not there (which is our case since there is no space in the hello message), strchr() will return NULL which refers to 0×0 memory address location.
Such memory address is a very special address. Basically any read attempt from there is threated as incorrect operation and results in memory access violation (not only in LoadRunner).
Now, howto deal with it? If you see ACCESS_VIOLATION, in most cases it means that your LR script is working on incorrect/incomplete values. You are responsible for error handling in your scripts and you should always:
- validate parameter’s values
- check results of C functions to handle any errors, unexpected conditions
- remember that you can’t always expect correct values and you need to handle it as well
Here is our example with fix showing howto deal with ACCESS_VIOLATION. We are calling strchr() function and checking if value returned is not NULL.
-
Action()
-
{
-
char * x_p;
-
-
lr_save_string("hello_world!", "MESSAGE");
-
x_p = (char *)strchr(lr_eval_string("{MESSAGE}"), ‘ ‘);
-
-
if(x_p) // if the pointer is not NULL display correct message
-
{
-
lr_save_string(x_p, "MESSAGE_FROM_SP");
-
lr_output_message(lr_eval_string("{MESSAGE_FROM_SP}"));
-
}
-
else //if pointer is NULL display error message
-
{
-
lr_error_message("Space not found in MESSAGE parameter");
-
}
-
return 0;
-
}
More details about NULL pointer here http://en.wikipedia.org/wiki/Pointer_(computing)#The_null_pointer
LoadRunner
access_violation, LoadRunner, null