I need to capture and print all the browser steps being executed in test script into HTML report. I'm currently using protractor and protractor-html-screenshot-reporter for reporting. Can anyone suggest if this can be achieved using any tool or are there any api's for this. Desired sample is attached.

- 85
- 7
-
have you tried selenium? – atmd Jan 29 '15 at 11:24
-
How have you generated this sample report? Thanks. – alecxe Jan 29 '15 at 16:50
-
@atmd the question is tagged as `protractor` which is build on top of `webdriverjs` hence it is a selenium webdriver based framework. – alecxe Jan 29 '15 at 16:51
-
@alecxe this report is from Sahi Pro, I need to get a similar format in protractor. – Anirudh Banerji Jan 30 '15 at 07:58
1 Answers
In order to achieve what you are asking about, you need to understand what is going on under-the hood and how the browser actions you need to log are sent and executed.
Here is a very brief high-level overview.
Interactions between a webdriver, selenium server and a browser are happening through the JSON Wire Protocol
- JSON over HTTP:
See also: Protractor: How It Works.
In other words, finding an element, sending keys to an element, click etc are, basically, sent as HTTP requests that could be monitored and logged, see Monitoring JSON wire protocol logs. For instance, here are the Chrome service logs:
[2.389][INFO]: COMMAND FindElement {
"sessionId": "b6707ee92a3261e1dc33a53514490663",
"using": "css selector",
"value": "input"
}
[2.389][INFO]: Waiting for pending navigations...
[2.389][INFO]: Done waiting for pending navigations
[2.398][INFO]: Waiting for pending navigations...
[2.398][INFO]: Done waiting for pending navigations
[2.398][INFO]: RESPONSE FindElement {
"ELEMENT": "0.3367185448296368-1"
}
This is exactly what, for example, BrowserStack is doing. They are parsing the raw logs and producing a user-friendly report of all actions performed:
In protractor, the closest functionality to what you are asking about, is being currently developed under a timeline
plugin:
configure
plugins
section in your protractor config:plugins: [{ path: 'node_modules/protractor/plugins/timeline/index.js', outdir: 'timelines' }],
run tests
- open
timelines/index.html
report and see:
Basically, it parses the webdriver's "client" logs and builds a time frame highlighting the commands that were sent during a test session. This is something you can use as a starting point, explore the source code of the plugin.
-
-
@Alecxe- I'm having trouble with timeline plugin, there is no such plugin which came while installing protractor. Can you please tell me how to get this in my local machine. – Anirudh Banerji Jan 30 '15 at 09:33
-
@BonJovi this is available in protractor installed from the github, master branch. – alecxe Jan 30 '15 at 09:41
-
@Alecxe- thanks! got this working. Now only thing left is that the index.html doesn't shows anything, but the timeline.json does contains steps while were executed on browser. Not sure what exactly the reason is? – Anirudh Banerji Jan 30 '15 at 10:41
-
1I'm getting Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///C:/DPC/workspaces/automation/dpc-login-plugin/timelines/timeline.json' on the console. – Anirudh Banerji Jan 30 '15 at 11:03