how to check that tag does not contain spaces or null as value using regular expression - jmeter

I am trying to validate a string (containg numbers, alphabets and spaces in between words and also contains trailing and leading white spaces) .I need a regular expression which i can put in response assertion of jmeter

Standard recommendation not to use regular expressions for working with HTML and/or XML.
Go for XPath Assertion instead, using it you can implement your requirement using XPath query like:
//yourElement[#yourTag!='null' and not(contains(#yourTag,' '))]
XPath language is quite easy, at least it is much easier to create and read XPath expressions rather than "regular" ones. Check out XPath Tutorial to get started and How to Use JMeter Assertions in Three Easy Steps guide to learn more about assertions available in JMeter.

Related

I need to extract a request number from "response data"

I am trying to use Regular expression extractor to extract, but i don't know how to use it here. Since the "request number" is visible only in "Response Data" of "View result tree". where should i place the post processor. what would be my regular expression.
edit: I have added my regular expression and result screen
Your response value is a number, without double quotes, so change your Regular expression to
"response":(\d+)
Parsing JSON data using regular expressions is not the best idea, I believe you should be using JSON Extractor instead.
It's available since JMeter version 3.0 and you should be able to use it instead of the Regular Expression Extractor.
The relevant JsonPath query will be as simple as:
$.response
Full configuration just in case:
Also be aware that according to JMeter Best Practices you should always be using the latest version of JMeter so consider migrating to JMeter 5.0 (or whatever is the latest version available at JMeter Downloads page) on next available opportunity.

Standard process for creating complex xpath in protractor

I am looking for standard ways to arrive at complex xpath expressions in protractor.
For e.g. I have a complex xpath as follows:
(//*[contains(#class,'day')][normalize-space(text())='2'])[1]
Here I have to get first access to elements matching xpath
//*[contains(#class,'day')][normalize-space(text())='2']
and then pick the first from the matching ones. Any pointers?
Protractor in its documentation clearly describes any process for creating xpaths:
http://www.protractortest.org/#/style-guide [section Locator strategies].
Firstly, you shouldn't use XPath except as a last resort. I second the recommendation by #Kacper to read the style guide he posted.
However, if you're dead set on using XPath, (sometimes it is unavoidable), you can pick the first element that matches like so:
element.all(by.xpath("//*[contains(#class,'day')][normalize-space(text())='2']")).first();

JMeter: How to ignore dynamic parameters in response assertions

I have to ignore dynamic property value while cmpmarison. Can you please suggest how to do so.
Currently I have used as
(\d+)
And Pattern matching Rule as "Contains"
Can anyone please help on same
regards
Vishal
Given your current setup, if the response will contain any number - your assertion will pass, otherwise it will fail. You can use Perl5-style regular expressions to handle dynamic response parts and static strings for doing the checks. See How to Use JMeter Assertions in Three Easy Steps article for more information.
The other approach is extracting the dynamic parts using Regular Expression Extractor, converting them into JMeter Variables and using these variables in the Response Assertion. Regular Expression Extractor is executed before the assertion so this way you will be able to work it around in a more "transparent" way.

Jmeter regex failing

How do I get the text "Need to grab this" using Jmeter - Regex
"suggestionsIdentifiers":[{"#v":"some other variable","#t":"string"}],"saveInto":["need to grab this"],"labelPosition":"ADJACENT","#t":"PickerField"}]}]}
It isn't very recommended to use Regular Expressions to work with JSON entities as they're quite complex, multiline, you need to escape a lot of characters, etc. so regular expressions are hard to develop and quite fragile.
I would recommend switching to JSON Path Extractor available via JMeter Plugins, it works with JSON like a charm.
JSON Path expression would be something like:
$..saveInto[0]
N.B. your response is not full, it doesn't look like a valid JSON so if you have any problems - please update your question with the full response so we could suggest an appropriate JSON Path
See Using the XPath Extractor in JMeter (Scroll down to "Parsing JSON") for plugin installation instructions and some form of JSONPath language reference.

Some websites not allowed to be parsed by xpath?

I am trying to parse one element from a website that is inside of a table. This is the exact xpath expression that I use:
[xpathParser search:#"/table[1]/tr[2]/td[1]"];
However, when I run the program, my string comes up empty. I'm wondering if the site is blocking me from parsing, or whether my expression is correct. If it helps, this is the site, and the piece I am trying to parse is the element Atlantic.
http://cluster.leaguestat.com/download.php?client_code=ahl&file_path=daily-report/daily-report.html
There are several 'atlantic' sections on the page, not sure what you mean by the element Atlantic. Your xpath expression might not be correct, as the 'tr' is not a direct descendant of table (there is a tbody in between). You might want to try //table/tbody/tr[2]/td[1], as well as the xpath checker firefox plugin to test expressions.

Resources