Extracting a link with jmeter - xpath

So I need to delete an "onclick" dynamic link using jmeter.
Here is the sample of one of the links:
"Delete"
What I need is to extract number and post it in order to do the delete action. Every link is the same except the number.
I have tried to implement some of the solutions I've found on this site but it didn't work.
Thanks in advance
Peace

If you need to do it with XPath you could try going for substring-after function like:
substring-after(//a[text()='Delete']/#href,'param=')
The above expression returns everything which is after param= text in href attribute of a HTML tag having Delete text.
You can test your XPath expressions against actual server response using XPath Tester tab of the View Results Tree listener.
References:
substring-after Function Reference
XPath 1.0 Language Reference
Using the XPath Extractor in JMeter
XPath Tutorial

Related

How to write assertion for dynamically change dropdown value in Jmeter

I have prepared my script using Correlation-regular expression. How can I provide the assertion for account which is selected from .csv file. Here the account selection is stored in a regular expression as follows.
CSV_Data_set_Config, CSV_File_info, Account_Selection_From_UI, Regular_Expression, Sample_Thread_Group, Response_Assertion
Your screenshots are very beautiful but you need to specify what do you want to compare with what in order to get a comprehensive answer.
If you need to compare this 0048852 with the value from the CSV file you need to:
Extract this 0048852 using Regular Expression Extractor or Boundary Extractor
Add Response Assertion as a child of the request and configure it like:
For more detailed response you need to share at least partial HTML code of the page where the dropdown is selected showing the dropdown markup and indicate what exact value you need to "assert"

Use XPath in JMeter to get attribute value

Below is a sample response from JMeter tool.
<input name="requestId" type="hidden" value="-1859748216"/>
I try the following XPath //input[#name='requestId'], but it doesn't work, I would like to take only the numeric value -1859748216
You need to get the value attribute using /#value
//input[#name='requestId']/#value
Prefer using newer/improved XPath2 Extractor over XPath Extractor
If you really want to use XPath, you need something like //input[#name='requestId']/#value
However XPath Extractor is quite resource intensive as it keeps entire DOM in memory, when it comes to getting the values from HTML content I would rather recommend going for CSS Selector Extractor leaving XPath for XML or when CSS Selectors are not powerful enough
Example setup:
More information:
CSS Selectors Reference
How to Use the CSS/JQuery Extractor in JMeter

Jmeter: String Index Out of Bounds Exceptions on Xpath

Can some one please please help me on this. I am tired of looking into it.
In while loop I am reading data from csv file, navigate to web pages and get Xpath values.
I get String Index out of bounds exceptions on Xpath.
Please see this screenshot of program
Steps to execute were
1.dealers.tt -- HTTP request
2.edit_integrtaion_details.tt --- HTTP request
3.Dealer details -- HTTP Request
then Xpath entities under Dealer details
For some reason some of the records read from file... only 2 steps get executed as below.leaving other steps (3 and Xpath)
dealers.tt
edit_integrtaion_details.tt
then I get an error as
'Dealer details' : java.lang.StringIndexOutOfBoundsException: String index out of range: 8193
I tried selecting redirect automatically and follow redirects in HTTP requests to force step 3 to execute. In both cases get this error.There are no spaces for the name I get from Xpath
Most likely you are sufferin from JTidy issue #205, the options are in:
Uncheck "Use Tidy" box, if your response is valid XML or XHTML it might be the case you don't need it (unlikely though)
Compile latest JTidy from the source code and once done replace jtidy-r938.jar in "lib" folder of your JMeter installation with the brand new JTidy jar.
Switch to CSS/JQuery Extractor
Switch to Regular Expression Extractor
If XPath is totally a must you can also consider JSR223 PostProcessor and Groovy language, it has built-in support of some form of XPath. Check out Groovy Is the New Black article for more details.

How to enter a web page , save the paramter response and use it to enter another page with this pramter

i need your help with a problem i encounter with jmeter
i need to create the following:
Enter a web page
Save from the response of the page a parameter
Use this parameter to enter another page
someone have an answer to my problem
thanks
A bit generic, but here goes:
HTTP sampler to make the request
Regular Expression Extractor (or Xpath) post processor to get the
data you need from the response.
HTTP sampler using variable from step 2
Links:
Regular Expressions
http://community.blazemeter.com/knowledgebase/articles/65150-using-regex-regular-expression-extractor-with-jm
Xpath
http://blazemeter.com/blog/using-xpath-extractor-jmeter-0
Ophir is correct.
Extract the parameter using regular expression extractor and the parameter value can be put into next request using the reference name specified in regular expression extractor.
eg: https://www.example.com/search?q=${reference},
Hope these links will help you.
http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
http://jmeter.apache.org/usermanual/regular_expressions.html
http://chinmaybrahma022.wordpress.com/2013/12/14/jmeter-regular-expression-extractor-postprocessor/
http://www.tutorialspoint.com/jmeter/jmeter_regular_expressions.htm

JMeter XPath results are missing expected items

Using XPath assertion: //ul/#class after a HTTP request, the assertion returns:
success_message_1=links
success_message_2=accordion vertnav vertnav-top grid-full
success_message_3=grid-full classic
success_message_4=checkout-types
success_message_5=links
success_message_matchNr=5
It is missing exactly one element, which happens to be the success message I need to find. The structure of the success message is:
<ul class="messages"><li class="success-msg"><ul><li>Message</li></ul></li></ul>
Strangely targeting the item with //li[#class="success-msg"] returns nothing. Using jQuery I did a simple jQuery('ul') and it matches all of the <ul> including the missing one.
I've checked the response and the success message does exist in the response, but why can't I select it with XPath?
The correct XPath expression if you need to obtain "Message" "vanilla" XPath selector will look like
//li[#class='success-msg']/ul/li/text()
If your page is not XML/XHTML compliant you may require to enable "Use Tidy" box in your XPath Assertion.
Particularly for your code following XPath Assertion works for me:
//li/text()='Message'
You may wish to use XPath Extractor combiner with Debug Sampler and View Results Tree listener to see what is the output of your XPath queries and once you'll get "true" - the query is OK to be used in the assertion.

Resources