Selenium:Webdriver:在WebDriver启动的浏览器会话中是否有侦听器来捕获用户操作? [英] Selenium:Webdriver: Is there a listener to capture user actions in the browser session launched by WebDriver?

查看:222
本文介绍了Selenium:Webdriver:在WebDriver启动的浏览器会话中是否有侦听器来捕获用户操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Selenium2/Webdriver创建一个基本的记录工具,并且我知道Selenium已经提供了一个IDE,但是我想构建一个更通用的IDE.

I am trying to create a basic recording tool using Selenium2/Webdriver and I am aware that Selenium Already provides an IDE, but I want to build a more generic one.

更具体地说,一旦我使用Java中的WebDiver API启动浏览器,便想在当前会话中注册一个侦听器,以便捕获与WebDriver启动的浏览器的用户交互.基本上,如果我要用Java编写记录用户交互,该怎么做?与EventFiringWebDriver类非常相似,但是该类在驱动程序启动命令而不是borwser会话时通知侦听器.

More specifically, once I launch the browser using WebDiver API in java, I would like to register a listener with the current session so I can capture user interaction with the WebDriver's launched browser. Basically if I were to write record user interactions in Java, how can I do it? Very similar to EventFiringWebDriver class, but this class notifies the listener when the driver initiates the command and not the borwser session.

例如,说我使用以下命令启动浏览器:

For example say I launch a browser with the following commands:

WebDriver驱动程序=新的FirefoxDriver();

WebDriver driver = new FirefoxDriver();

现在打开一个空白的firefox浏览器,底部显示WebDriver为红色.现在,假设我在此浏览器中输入www.google.com,然后按Enter.浏览器将我导航到google.com.我可以注册一个侦听器,该侦听器在此浏览器会话上发生的事件时通知我吗?

Now there is a blank firefox browser open which says WebDriver on the bottom in red color. Now suppose I type www.google.com in this browser and press enter. The browser navigates me to google.com. Can I register a listener that notifies me on events that occurs on this browser session?

感谢您的帮助.

推荐答案

我对监听器不熟悉.我知道人们倾向于使用 BrowserMob代理之类的工具来充当中间人捕获并重播HTTP操作.由于WebDriver使用JSON Wire Protocol运行,因此我认为这可能更适合您的需求.

I'm not familiar with the listeners. I know that people have tended to use something like BrowserMob Proxy to act as a man-in-the-middle to capture and replay HTTP actions. Since WebDriver runs using the JSON Wire Protocol, I think this may be more suited for what you're looking for.

此外,Simon Stewart(WebDriver的创建者)详细介绍了Selenium WebDriver项目的理念和体系结构.您可以在此处看到.

Also, Simon Stewart (the creator of WebDriver) has a detailed write-up on the philosophies and architecture of the Selenium WebDriver project. You can see that here.

干杯, 戴夫H

这篇关于Selenium:Webdriver:在WebDriver启动的浏览器会话中是否有侦听器来捕获用户操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆