如何使用 capybara-webkit 获取响应标头和时间

发布于 2025-01-03 02:56:54 字数 187 浏览 2 评论 0原文

如何使用 capybara-webkit 获取网页中单独 ajax 请求的响应?

是否有任何特定方法可以捕获每个请求的响应时间?

笔记: 我正在将水豚与 rspec 一起使用。

例如:我在一个网页中有 3 个 Ajax 请求。我需要获取每个请求的单独响应时间和整个网页的响应时间。

谢谢, 普里亚

How to get response of seperate ajax requests in a web page using capybara-webkit?

Is there any particular method available to capture response time of each request?

Note:
Am using capybara with rspec.

For eg: i have 3 Ajax requests in a web page. I need to get separate response time of each request and the response time of entire web page.

Thanks,
Priya

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难如初 2025-01-10 02:56:54

一般来说这是不可能的,因为网络服务器在不同的进程中运行,但您可以创建一个自定义机架中间件并将所有响应转储到单独的日志文件。首先,您可以实现此处描述的技术:https://gist.github.com/2975611转储标头您可以使用 http://rack.rubyforge.org/doc/Rack/ContentLength.html

Generally it's not possible since webserver is running in the different process but you could create a custom rack middle-ware and dump all responses to the separate log file. For the beginning you could implement technique described here: https://gist.github.com/2975611 and for dumping headers you could use some code snippets from http://rack.rubyforge.org/doc/Rack/ContentLength.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文