Selenium:Webdriver: Is there a listener to capture user actions in the browser session launched by WebDriver?

你。 提交于 2019-12-09 13:03:26

问题


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.

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 driver = new FirefoxDriver();

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?

I appreciate your help.


回答1:


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.

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.

Cheers, Dave H




回答2:


There is indeed a WebDriverEventListener .See the doc link. Cheers.




回答3:


i had idea. that we clound use selemius to execution js code. look like ff.execute_script("alert('hello,selenium')") you can edit js to you want like onclick or onmove....



来源:https://stackoverflow.com/questions/16746757/seleniumwebdriver-is-there-a-listener-to-capture-user-actions-in-the-browser-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!