Useful JMeter functions for scripting

Preview:

DESCRIPTION

This is a small presentation to illustrate some of the basic JMeter functions/ features that can be used to accurately construct JMeter scripts

Citation preview

JMeter Features

By Tharinda Liyanage

XPath• XPath is used to navigate through elements and attributes in an XML

document//form[@name='fm1']//input[@name='lt']/@value

XPath Extractor

//form[@name='fm1']//input[@name='lt']/@value

• JMeter variable – ${t}

Regular Expression

• Matches string patterns

• input type="hidden" name="lt" value="(.*)"

Reference Name: MYREF Regex: name="(.+?)" value="(.+?)" Template: $1$$2$

Reg Ex

• ( ) - grouping • [ ] - character classes • { } - repetition • * + ? - repetition • . - wild-card character • \ - escape character • | - alternatives • ^ $ - start and end of string or line

Functions• __log()• __threadNum()- The thread number function simply returns the number of the thread currently being

executed ${__log(${__threadNum},,,******Thread_Number is*********:: )}

• __machineName() The machineName function returns the local host name

• __RandomString ()

RandomString(var1,var2,var3),where:var1 - Random string lengthvar2 - Chars to use for random string generationvar3 - Name of variable in which to store the result (optional)

• Counter

Database Testing• Step 1: Put downloaded JDBC driver (sqljdbc4.jar) under "JMeter/lib/" directory. • Step 2 : Adding JDBC Connection Configuration

• Step 3: Adding JDBC Request