extracting attribute values from css nodes then transforming it array of attrib. values

I am new to Scala as well as Gatling. I first tried doing a print of my variables as in:

println(session.getAttribute(“mykeytovar”)) // var is css(…).findAll.saveAs(“mykeytovar”)

But I noticed the print didn’t give me anything … only a list of commas.

What I really want to do is to access the css nodes from findAll and perform a series of steps as in extracting attribute values from the css nodes. Ideally I want to ‘map’ each node when I do:

http(“My Request”).get(“myUrl”).check(status.is(200),
css("div … ")
.transform( ? ) // return some sort of map(extract_attrib_values) which returns a collection
.transform( ? ) // randomly pick 1

Is there any easy way to do this? I prefer to use css selector over regex in this case.


1/ The list of commas may be the right thing. Are you sure your CssSelector query contains some text ?
css(#foo) → get the text in the tag having the ‘id=foo’
css(#foo, bar) → get the value of the attribute ‘bar’ from the tag having the ‘id=foo’

Thanks Nicolas

  1. I’ll inspect this further but I think you may be right on the div. So I’ll try this with something else later and see if it returns the innerHTML. For the attribute, is there a way to get multiple attributes? LIkely this isn’t there so I may have to write something custom.

  2. I’ll look to changing this.

Thanks Nicolas!