Gatling脚本中的变量未定义

时间:2016-04-07 16:14:51

标签: gatling

Gatling Newbie来了。我正在尝试使用下面记录的css选择器检查我的页面的html。 css项目出现在页面上(用邮递员验证)但是Gatling没有找到它。我在编译时收到一个变量未定义的错误。任何建议都将不胜感激。

import scala.concurrent.duration._

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._

class LoggingIn extends Simulation {

    val httpProtocol = http
        .baseURL("https://test.spidastudio.com")
        .inferHtmlResources(BlackList(""".*\.js""", """.*\.css""", """.*\.gif""", """.*\.jpeg""", """.*\.jpg""", """.*\.ico""", """.*\.woff""", """.*\.(t|o)tf""", """.*\.png"""), WhiteList())

    val headers_0 = Map(
        "User-Agent"-> "Gatling",
        "Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
        "Accept-Encoding" -> "gzip, deflate",
        "Cache-Control" -> "max-age=0",
        "Origin" -> "https://test.spidastudio.com",
        "Upgrade-Insecure-Requests" -> "1")

    val headers_1 = Map("User-Agent"-> "Gatling","X-Requested-With" -> "XMLHttpRequest")

    val uri1 = "https://test.spidastudio.com"



    val scn = scenario("LoggingIn")
        .exec(http("REQUEST A")
            .post("/cas/login?service=https%3A%2F%2Ftest.spidastudio.com%2Fprojectmanager%2Fj_spring_cas_security_check")

            //Defining variable LTValue
            .check(css("input[name=lt]", "value").saveAs("LTValue"))
        )
        .exec(http("request_0")
            .post("/cas/login?service=https%3A%2F%2Ftest.spidastudio.com%2Fprojectmanager%2Fj_spring_cas_security_check")

            .headers(headers_0) 
            .formParam("username", "xxxxxxx.com")
            .formParam("password", "xxxxxxxx")
            //Calling variable
            .formParam("lt", "${LTValue}")

1 个答案:

答案 0 :(得分:0)

您是否尝试过在代码中删除此行?

.inferHtmlResources(BlackList(""".*\.js""", """.*\.css""", """.*\.gif""", """.*\.jpeg""", """.*\.jpg""", """.*\.ico""", """.*\.woff""", """.*\.(t|o)tf""", """.*\.png"""), WhiteList())

或删除* .css""" ?作品?