Wednesday, July 20, 2016

Add Cookie Dynamically in Jmeter Script by using Beanshell Preprocessor

Following is the syntax:


import org.apache.jmeter.protocol.http.control.Cookie;

sampler.getCookieManager().add(new Cookie("Cookiename", "CookieValue", "Hostname", "URL", true, Long.MAX_VALUE));


Monday, June 20, 2016

Common Issue in JMeter Script with Single Sign on Applications

One of the common issue in single sign on application is Correlation of SAML Request and SAML Response.

When we capture the SAML Req/ SAML Response by using correlation.

We will get in the following format:

PHNhbWxwOkF1dGhuUmVxdWVzdCAgeG1sbnM6c2FtbHA9InVybjpvYXNpczpuYW1lczp0YzpTQU1M
OjIuMDpwcm90b2NvbCIKSUQ9InMyNDEzMzFjNzk5MGVmMGZmZWRkMjJkYWQyNzdjMGYxNjdkMmE3


We need to replace the following and then pass to the next request.

 need to be replaced with %0D
+ need to be replaced with %2B

Following is the syntax we can use for replacing.

We can use JSR223 Processor - Groovy Language

def a =  ("${SAMLReq}".replaceAll('+'\,'%2B'));
def b =  (a.replaceAll('
'\,'%0D'));
//log.info("Final SAML Req : "+b );
vars.put ("SAML_Req",b);


Monday, May 2, 2016

JMeter Commands

Running the JMeter from Command Prompt by parameterizing the No of threads, Ramp up, duration and passing through the command prompt in windows.

jmeter -n -t "Record_Firefox.jmx" -Jno.threads=10 -Jno.rampup=10 -Jno.duration=700

Below syntax used to parameterize in the script
${__P(no.threads)}
${__P(no.rampup)}
${__P(no.duration)}


Running the JMeter from Command Prompt by parameterizing the No of threads, Ramp up, duration and passing through the command prompt in Linux.

./jmeter -n -t Record_Firefox.jmx -Jno.threads=10 -Jno.rampup=10 -Jno.duration=700 –j jmeter.log

Below syntax used to parameterize in the script
${__P(no.threads)}
${__P(no.rampup)}
${__P(no.duration)}

Recording or executing Internet URL using JMeter in an environment which uses proxy to connect to Internet.

jmeter.bat -H (ProxyIP) -P (ProxyPort) -N localhost -u domainname\username -a password


HTML Report Generation after completion of execution
jmeter.bat -n -t TEST.jmx -l  test1.log -e -o Report

HTML Report generation for already existing log  file

jmeter -g test.log -o Report

Monday, April 4, 2016

Launching Putty through Command Prompt

Create a Bat file ( Ex: openputty.bat)
Add below syntax in that file.

@echo on
"<C:\Program Files\PuTTY\putty.exe>" -ssh username@SERVERNAMEoriP -pw %1 22 -m command.txt

Password can pass as command line argument or can prove in the above command in place of %1

If you have multiple commands to execute in putty, You can add that commands in text file and pass as above. -m command.txt