XPath Assertion is useful to assert the page element's xpath. You tin larn to a greater extent than close XPath in addition to how to discovery it guide on THIS PAGE. Earlier nosotros learnt unlike assertions of jmeter to operate them inwards software charge exam conception in addition to hence i remember directly you lot are good aware close assertion. Let's larn XPath assertion amongst representative to know how to operate it inwards your practical software charge exam conception 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 produce real uncomplicated software charge exam conception to assert the xpath of http://jmeter.apache.org/ website's logo(See bellow given image) inwards jmeter charge exam plan. Function of XPath assertion is real simple. It volition depository fiscal establishment correspond if chemical part amongst given xpath is acquaint on page or not. Assertion volition exceed if given xpath is acquaint on page. Else it volition fail. Using xpath assertion you lot tin confirm that targeted chemical part is displayed on requested page.
I accept added ii asking in addition to xpath assertion nether both requests inwards my jmeter software charge exam plan. 1st request's xpath assertion has valid xpath(//img[@alt='Logo ASF']) in addition to 2d request's xpath assertion has invalid xpath(//img[@alt='Logo ASF1']) equally shown inwards bellow image. Actual XPath of logo is "//img[@alt='Logo ASF']".
Configuration of 1st request's XPath assertion is equally 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 equally bellow.
- Apply to = Main sample only.
- XML Parsing options : Selected options -> Use Tidy (tolerant parser), Quiet
- XPath Assertion = //img[@alt='Logo ASF1']
Only divergence inwards configuration of both xpath assertions is xpath syntax. Everything else is same.
HTTP Request configuration for both requests is same equally bellow.
Thread grouping config is equally bellow.
Now if you lot run higher upwards exam plan, lawsuit volition looks similar bellow.
In lawsuit you lot tin come across that 1st asking is pass. That agency nodes amongst given xpath syntax is establish on page. 2d request's xpath assertion is failed in addition to display Assertion failure message: "No Nodes Matched //img[@alt='Logo ASF1']".
This way you lot tin operate xpath assertion inwards your software charge exam conception to assert xpath of whatever element.