Verifying a <td> table cell returned from a function has a given title attribute?

Hi all,

Basically I want to check via a feeder that the returned search results on a given page (where the search is created via a POST) contain the correct data, either as:

  1. A count of rows that have a certain html attribute (i.e to tell me the expected number of results was returned)

  2. An “exists” when a given attribute matches something (e.g. a table cell () title="" attribute contains “foo”)

  3. A collection of table cell innertext that I can loop through
    Any ideas on how to implement this using a recorder-created scenario?

Hi,

1 and 2 are very easy: you just have to have an extra column for the expected result in the feeder used for setting the form params, and use a regex or css check.

Let’s say your feeder looks like this:
myFormParam,myExpectedCount
foo,3
bar,5

then, you can write a check such as css(“somethingThatSuitsYourNeeds”).count.is("${myExpectedCount}")

3 is a bit more complex. You could store in the feeder the concatenated list of expected innerTexts and concatenate in the check too with a transform step.

Cheers,

Steph

My bad, in 1.3, you can’t directly compare what comes from a feeder, which is a String, and a count which is an Int. You have to add a transform step such as:
css(“somethingThatSuitsYourNeeds”).count.transform(_.toString).is("${myExpectedCount}")

Thanks for the quick response. It didn’t seem to work though, so I added logging to the requests using this snippet on my httpConfig:

.responseInfoExtractor((response: Response) => { ListString })

I’m submitting a POST with some parameters (a search query), and I seem to be getting a JSON response back from the server with the following simplified structure:

{“id”:“1597574720”,
“result”:"{
“colModel”:
[{“name”:“SomeColumnName”,“width”:“100”,“label”:“Some Column Name”},
{“name”:“SomeOtherColumnName”,“width”:“150”,“label”:“Some Other Column Name”}]
,“colData”:
{“total”:1,“page”:1,“records”:2,“userdata”:{“SomeValue”:550.00,“SomeOtherValue”:500.00,“YetAnotherValue”:50.00}
,“rows”:
[{“id”:1,“cell”:[“December - 2010”,“User Name1”]},
{“id”:2,“cell”:[“December - 2010”,“User Name2”]}]
}
}",“error”:null}

  1. Could you please explain how I would extract the total records count from the above?
  2. Could you please explain how I would extract the User Names from the above?

I thought the answer to 1. might be:

.check(jsonPath("//result/colData/records").transform(_.toString).is(“2”))

but it doesn’t seem to work? I get “Check ‘is’ failed, found nothing”

Hi,

What are all these backslashes doing here?
Are they actually in the response (they shouldn't be)?

Stéphane

Moreover, there’s invalide double quote around result value:
“result”:"{ should be “result”:{

}",“error”:null} should be },“error”:null}