Hi,
I'm trying to find the way to read the next string after finding given text in response html.
It will contain fe. "someNum is: 1234" but the number will be different in every response.
My question is, how to grab the number, which sits in the string, when finding begginnig of the string which is "someNum is:"
if (oSession.oResponse.headers.ExistsAndContains("Content-Type", "html") {
oSession.utilDecodeResponse();oSession.utilFindInResponse("someNum is:");
var = <here I want to put the value, whatever it is>;
oSession.Log.LogString(var);
}
Thanks.
Well I tried but I cannot reach that string in fiddlerscript, I think it's fiddler specific as accessing the response code and withdrawing its html code requires some specific behavior.
I'm not sure how to access the string which I don't even read, I just FindInResponse string before the one I need to read. I think here is the clue.
I didn't get, what would utilReplaceInResponse give me there.
utilFindInResponse finds a part of the string "someNum is:" other part, which dynamically change is a number f.e. "123", so when I found with utilFindInResponse beginning, what would give me its returned index? I'm lost here.
Full string: "someNum is: 123", found string: "someNum is:", unknown: "number"
Ok, if you can use replace, then you still need to grab the whole response body, replace the part you are looking for, and then set the modified body.
oSession.utilDecodeResponse(); var oBody = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes); // Replace the string occurrence with the value you need e.g. while using ReGex or other techniques var myRegex = <some-regex-action-here> oBody = oBody.replace(myRegex, ""); // Set the response body oSession.utilSetResponseBody(oBody);
Thanks for your input, but I think you still missunderstand the issue here.
I don't want to replace anything, I just want to read the next string signs after "someNum is:" (which will be a number from 0-1000.
So I use here:
Let's say the full string is "someNum is: 123", and when I already find the "someNum is:" string, I want to check this value after the found string. So I want to store 123 (which changes, I don't know the num which I will find) and then print it with: