加特林.检查HTML结果是否包含某些字符串 [英] Gatling. Check, if a HTML result contains some string

查看:70
本文介绍了加特林.检查HTML结果是否包含某些字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编程加特林性能测试,我需要检查服务器返回的HTML是否包含预定义的字符串.它确实做到了,但由于错误而使测试失败.

Programming Gatling performance test I need to check, if the HTML returned from server contains a predefined string. It it does, break the test with an error.

我不知道该怎么做.一定是这样的:

I did not find out how to do it. It must be something like this:

  val scn = scenario("CheckAccess")
    .exec(http("request_0")
      .get("/")
      .headers(headers_0)
      .check(css("h1").contains("Access denied")).breakOnFailure()
      )

我将希望的功能称为包含"和"breakOnFailure".加特林有类似的东西吗?

I called the wished features "contains" and "breakOnFailure". Does Gatling something similar?

推荐答案

这里有解决方案

.check(css("h1").transform((s: String) => s.indexOf("Access denied"))
.greaterThan(-1)).exitHereIfFailed

这篇关于加特林.检查HTML结果是否包含某些字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆