记录或记录所有浏览器 DOM/JQuery 事件
我遇到了一个问题,需要以编程方式(在 JavaScript 中)执行一些操作,这些操作是在某些浏览器事件(单击、焦点、?)触发后在第三方组件中发生的。我不知道事件类型、事件绑定到的元素或正确的参数。
-尝试在子树修改上设置 Chrome 断点,但没有任何效果。
-尝试检查 jQuery 事件,但 data('events') 没有显示任何有用的信息 - 他们必须使用 DOM 事件。
难道不应该有某种方法在浏览器中记录/捕获/记录所有事件,然后检查它们(甚至回放它们)吗?这似乎是找出我想知道的东西的唯一方法。
I had a problem of needing to do some stuff programmatically (in javascript) that was happening in a third party component after being triggered by some browser events (click, focus, ?). I didn't know the event type, the element that the event was bound to, or the proper parameters.
-Tried setting Chrome breakpoints on subtree modifications, but nothing worked.
-Tried checking for jQuery events, but data('events') didn't reveal anything useful- they must be using DOM events.
Shouldn't there be some way of recording/capturing/logging all the events in a browser and then checking them (or even playing them back)? That seems like the only way to find out what I want to find out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
2021 年更新
您可以在任何基于 Chromium 的浏览器中执行此操作(例如 Brave、< a href="https://dissenter.com/" rel="nofollow noreferrer">异议者,Edge 等):
刷新会显示加载事件的顺序,您还可以过滤 AJAX、JS 和其他类型的事件。或者,您可以在“源”选项卡中为鼠标悬停等内容时发生的某些用户事件设置断点。
Updated for 2021
You can do this in any Chromium-based browser (e.g. Brave, Dissenter, Edge, etc.):
Refreshing will show you the sequence of load events, and you can also filter for AJAX, JS, and other types of events. Or you can set breakpoints in the Sources tab for certain user events that happen when you mouse-over stuff, etc.
在 Chrome 中,您可以在开发工具的控制台中使用
monitorEvents()
来记录您想要监控的测试期间触发的所有事件。In Chrome you can use
monitorEvents()
in the console of dev tools to record all the events that you would like to monitor triggered during your test.