XPath Assertion is useful to assert the page element's xpath. You tin acquire to a greater extent than nearly XPath together with how to honour it postulate on THIS PAGE. Earlier nosotros learnt unlike assertions of jmeter to purpose them inward software charge examination innovation then i recall forthwith you lot are good aware nearly assertion. Let's acquire XPath assertion amongst example to know how to purpose it inward your practical software charge examination innovation using jmeter.
Add XPath Assertion In Software Load Test Plan
Mostly XPath assertion is beingness added nether request. To add together it nether request,
- Right click on asking -> Add -> Select Assertions -> XPath Assertion. See bellow given image.
It volition add together XPath assertion nether request.
Example : Assert XPath Of Element Using XPath Assertion
I accept develop real elementary software charge examination innovation to assert the xpath of http://jmeter.apache.org/ website's logo(See bellow given image) inward jmeter charge examination plan. Function of XPath assertion is real simple. It volition cheque if chemical component subdivision amongst given xpath is acquaint on page or not. Assertion volition piece of occupation past times if given xpath is acquaint on page. Else it volition fail. Using xpath assertion you lot tin confirm that targeted chemical component subdivision is displayed on requested page.
I accept added ii asking together with xpath assertion nether both requests inward my jmeter software charge examination plan. 1st request's xpath assertion has valid xpath(//img[@alt='Logo ASF']) together with 2d request's xpath assertion has invalid xpath(//img[@alt='Logo ASF1']) every bit shown inward bellow image. Actual XPath of logo is "//img[@alt='Logo ASF']".
Configuration of 1st request's XPath assertion is every bit bellow.
- Apply to = Main sample only.
- XML Parsing options : Selected options -> Use Tidy (tolerant parser), Quiet
- XPath Assertion = //img[@alt='Logo ASF']
Configuration of 2d request's XPath assertion is every bit bellow.
- Apply to = Main sample only.
- XML Parsing options : Selected options -> Use Tidy (tolerant parser), Quiet
- XPath Assertion = //img[@alt='Logo ASF1']
Only divergence inward configuration of both xpath assertions is xpath syntax. Everything else is same.
HTTP Request configuration for both requests is same every bit bellow.
Thread grouping config is every bit bellow.
Now if you lot run inward a higher house examination plan, consequence volition looks similar bellow.
In consequence you lot tin run across that 1st asking is pass. That agency nodes amongst given xpath syntax is institute on page. 2d request's xpath assertion is failed together with display Assertion failure message: "No Nodes Matched //img[@alt='Logo ASF1']".
This way you lot tin purpose xpath assertion inward your software charge examination innovation to assert xpath of whatever element.