捕获网络浏览器或 watin 中的用户活动
有没有办法检测WebBrowser中所有可能的用户活动并返回自定义事件?例如:用户点击“搜索”按钮,返回“SearchButtonClicked”自定义事件。
这就像记录用户所做的所有活动,按顺序存储,并且可以在他想要的时候自动化。
编辑:我不拥有该网页。我正在尝试制作一个应用程序来自动在谷歌上进行一些搜索。
Is there any way to detect all the possible user activities within a WebBrowser and return a custom Event? For example: User clicks on "search" button, return "SearchButtonClicked" custom Event.
It would be something like, logging of all the activity that user does, stored in a sequence and could be automated once he wanted.
Edit: I do not own the webpage. I am trying to make an application to automate some searching on google.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
经过一番研究,我发现了
HtmlElementEventHandler
。例子:
After some research, I discovered the
HtmlElementEventHandler
.Example:
哇,这将是一个带宽密集型应用程序...:) 例如,您可能会考虑使用像 jQuery 这样的框架,将事件附加到所有锚点和按钮类型输入,以对服务器执行 AJAX 调用。因此,您可能会执行以下过程:
在所有页面上包含一个 JS 文件来执行类似以下操作:
创建一个可以通过 AJAX 调用的 Web 方法来跟踪用户活动:
在 OP 编辑之后,您不拥有该应用程序,因此这不起作用。我将答案保留在这里,以供将来可能有类似需求的人使用。
Wow, it's going to be quite a bandwidth intensive application... :) You might consider a framework like jQuery to attach events to all anchors and button-type inputs to perform AJAX calls to your server, for example. So you might have something along the lines of the following process:
Include a JS file on all your pages to do something like the following:
Create a Web Method that can be called via AJAX to track the user activity:
After your OP edit, you don't own the application, so this won't work. I'm keeping the answer here for someone in the future who might have a similar need.
查看HtmlElementEventHandler的类型:
http://msdn .microsoft.com/en-us/library/system.windows.forms.htmlelement_events%28v=vs.110%29.aspx
使用此事件处理程序知道事件发生。事件发生时,获取元素详细信息、标签详细信息并使用事件类型登录文件。
查看使用 HtmlElementEventHandler 时所需的向下转型的用法
http://www.hanselman.com/blog/BackToBasicsThisIsNotTheObjectYoureLookingwaitOhItIsTheObject.aspx。
当您想要重播操作时,您可以在提取标签名称和值字段后按顺序运行记录的事件。
See types of HtmlElementEventHandler:
http://msdn.microsoft.com/en-us/library/system.windows.forms.htmlelement_events%28v=vs.110%29.aspx
Use this event handler for knowing event occured. On event occured, get the element details, tag details and log in the file with the type of event.
See usage of downcasting required when using HtmlElementEventHandler
http://www.hanselman.com/blog/BackToBasicsThisIsNotTheObjectYoureLookingwaitOhItIsTheObject.aspx.
When you want to replay action, you may run logged events in sequence, after extracting tag name and value fields.