I want the value of meta keywords and it returns null in both the cases
So what I want is to look for the value of meta keyword only if below XPath exists.
//html/head/meta[@name='keywords']/@content
if (keywordXPath.exists()){ // ----> how to do it in Groovy JSR223 Assertion?
if (keyword.equals("") || keyword == null) {
// to do
} else {
// to do
}
}
How can I check XPath present or not in Groovy JSR223 Assertion?
It sounds you're going into wrong direction.
However these methods assume your response is valid XML or XHTML , any inconsistency - and your code will fail
So I would rather use JMeter's XPath2 Extractor to store the "interesting" values from the response into JMeter Variables and then use vars
shorthand for JMeterVariables class instance to see whether the variable is defined or not like:
if (vars.get('variable from XPath2 Extractor`) != null) {
//your code here
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.