I have a script that was recorded against a server that didn't use HTTPS. I want to play back against a server using HTTPS. However I couldn't just change the server name and add a SSL connection to the server config. The new server uses WebSeal and all the requests from the non-HTTPS test had to be prefaced with "/wp".
To illustrate this technique I made a small test recorded against Wikipedia:
I would want, for example
to be changed to
for that specific request as well as all the others.
This could be done with search and replace in RPT but the changes wouldn't be persistent and would have to be done with each new recording. In addition, search and replace may replace the string that's already correlated. We want the change to affect URL's used in requests that are not correlated.
This can be done rather easily using data correlation rules. Here's how to do it.
1. Create a variable with the value of the prefix, I called mine wp_slash. We have to use variable instead of a reference because the value "/wp" will not be returned in any response content before we do the first substitution.
2. Find the first "/" in the test, highlight it, then right mouse click and chose Substitute -> Select Data Source....
3. Select the variable we just made, slash_wp
4. Do the substitution and then save the test. Don't try to substitute everything at this point. Our goal is to create a rule to do this and the rule will do the substitution for us
5. Now lets look at the rule. Note the regular expression for the substituter. It's .* which means it will replace the entire string with "/wp/". We don't want that.
6. Change the regular expression to "^(/)" when means substitute only the leading "/"
7. Save the rule and apply it to the test
8. It probably looks like nothing's changed, but compare the test with the previous picture of the test. All the /'s are now purple.
9. Run the test. I expect it to fail because for Wikipedia the URL is invalid but the test log will show that /wp was prefaced for all the requests