[英]In gatling, how do I validate the value of a string extracted via the css check?
我正在編寫一個加特林(Gatling)模擬,我想驗證某個元素是否存在,以及其中一個屬性的內容是否以某個子字符串開頭。 例如:
val scn: ScenarioBuilder = scenario("BasicSimulation")
.exec(http("request_1")
.get("/path/to/resource")
.check(
status.is(200),
css("form#name", "action").ofType[String].startsWith(BASE_URL).saveAs("next_url")))
現在,當我在上面添加startsWith
,編譯器會報告一個錯誤,指出startsWith is not a member of io.gatling.http.check.body.HttpBodyCssCheckBuilder[String]
。 如果我將startsWith
留在外面,那么一切都很好。 我知道期望的表單元素在那里 ,但我無法確認其@action
屬性以正確的基數開頭。
如何確認屬性以某個子字符串開頭?
請參閱此https://gatling.io/docs/2.3/general/scenario/
我從那里復制了以下內容,但這是一個會話函數,將如下所示工作:-
doIf(session => session("myKey").as[String].startsWith("admin")) { // executed if the session value stored in "myKey" starts with "admin" exec(http("if true").get("..."))}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.