useful jmeter functions for scripting
DESCRIPTION
This is a small presentation to illustrate some of the basic JMeter functions/ features that can be used to accurately construct JMeter scriptsTRANSCRIPT
![Page 1: Useful JMeter functions for scripting](https://reader033.vdocuments.site/reader033/viewer/2022061201/547932f65806b594048b4638/html5/thumbnails/1.jpg)
JMeter Features
By Tharinda Liyanage
![Page 2: Useful JMeter functions for scripting](https://reader033.vdocuments.site/reader033/viewer/2022061201/547932f65806b594048b4638/html5/thumbnails/2.jpg)
XPath• XPath is used to navigate through elements and attributes in an XML
document//form[@name='fm1']//input[@name='lt']/@value
![Page 3: Useful JMeter functions for scripting](https://reader033.vdocuments.site/reader033/viewer/2022061201/547932f65806b594048b4638/html5/thumbnails/3.jpg)
![Page 4: Useful JMeter functions for scripting](https://reader033.vdocuments.site/reader033/viewer/2022061201/547932f65806b594048b4638/html5/thumbnails/4.jpg)
XPath Extractor
//form[@name='fm1']//input[@name='lt']/@value
![Page 5: Useful JMeter functions for scripting](https://reader033.vdocuments.site/reader033/viewer/2022061201/547932f65806b594048b4638/html5/thumbnails/5.jpg)
• JMeter variable – ${t}
![Page 6: Useful JMeter functions for scripting](https://reader033.vdocuments.site/reader033/viewer/2022061201/547932f65806b594048b4638/html5/thumbnails/6.jpg)
Regular Expression
• Matches string patterns
• input type="hidden" name="lt" value="(.*)"
Reference Name: MYREF Regex: name="(.+?)" value="(.+?)" Template: $1$$2$
![Page 7: Useful JMeter functions for scripting](https://reader033.vdocuments.site/reader033/viewer/2022061201/547932f65806b594048b4638/html5/thumbnails/7.jpg)
Reg Ex
• ( ) - grouping • [ ] - character classes • { } - repetition • * + ? - repetition • . - wild-card character • \ - escape character • | - alternatives • ^ $ - start and end of string or line
![Page 8: Useful JMeter functions for scripting](https://reader033.vdocuments.site/reader033/viewer/2022061201/547932f65806b594048b4638/html5/thumbnails/8.jpg)
Functions• __log()• __threadNum()- The thread number function simply returns the number of the thread currently being
executed ${__log(${__threadNum},,,******Thread_Number is*********:: )}
![Page 9: Useful JMeter functions for scripting](https://reader033.vdocuments.site/reader033/viewer/2022061201/547932f65806b594048b4638/html5/thumbnails/9.jpg)
• __machineName() The machineName function returns the local host name
![Page 10: Useful JMeter functions for scripting](https://reader033.vdocuments.site/reader033/viewer/2022061201/547932f65806b594048b4638/html5/thumbnails/10.jpg)
• __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)
![Page 11: Useful JMeter functions for scripting](https://reader033.vdocuments.site/reader033/viewer/2022061201/547932f65806b594048b4638/html5/thumbnails/11.jpg)
• Counter
![Page 12: Useful JMeter functions for scripting](https://reader033.vdocuments.site/reader033/viewer/2022061201/547932f65806b594048b4638/html5/thumbnails/12.jpg)
Database Testing• Step 1: Put downloaded JDBC driver (sqljdbc4.jar) under "JMeter/lib/" directory. • Step 2 : Adding JDBC Connection Configuration
![Page 13: Useful JMeter functions for scripting](https://reader033.vdocuments.site/reader033/viewer/2022061201/547932f65806b594048b4638/html5/thumbnails/13.jpg)
• Step 3: Adding JDBC Request