简体   繁体   中英

how to extract token generated by js script (challenge.flood.io)

I am currently studying Gatling for performance testing, I am new to both. Making the task, I have stuck on the step when I need to get a token to pass it to parameter to get to the other page. The difficulty for me is that the token is absent in the body, it is generated by a script, so I cannot get it with...check(css(... or check(regex(...

在此处输入图像描述

I tryed to get the token by css and regex, getting empty result

.exec(
  http("Step 5 page")
    .get("${redirection}")
    .check(status.is(200))
    .check(substring("Step 5"))
    .check(css("input[name='challenger[step_id]']", "value").find.saveAs("step_id"))
    .check(css("input[name='challenger[step_number]']", "value").find.saveAs("step_number"))
    .check(css("input[name='commit']", "value").find.saveAs("commit"))
    .check(css("span.token").find.saveAs("one_time_token")))

How can I get the token?

It's pretty clear from this code that this page is performing an extra ajax request to the /code url to fetch the token and then display it in the page.

You'll find the value in there (you can see this HTTP request a few lines below in the Network tab).

Note: in order to learn Gatling you should probably check the Gatling Academy .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM