How do I enable source maps in ChromeDriver?

65 views
Skip to first unread message

Carl Erik Kopseng

unread,
Aug 5, 2019, 5:23:55 AM8/5/19
to ChromeDriver Users
This is a typical error from our Selenium tests when something goes wrong in the javascript bundle:
09:27:09.540 [main] ERROR gui.rule.ScreenshotRule - Chrome console: SEVERE https://localhost:56962/bundle.js 94:74996 TypeError: Cannot read property 'map' of undefined

When debugging this manually Chrome takes use of the source map to give me I find this a bit strange, given that source maps have been enabled by default in Chrome since version 39. I am guessing this only applies when DevTools are open, but is there a way of instructing ChromeDriver to enable them?

Regards
Carl-Erik Kopseng

Carl Erik Kopseng

unread,
Aug 5, 2019, 9:56:53 AM8/5/19
to ChromeDriver Users
As a temporary solution I hacked together a tool based on Stacktrace.js to get the original line numbers manually on the CLI:

 npx @fatso83/stacktrace-cli dist/app-bundle.js* 129:600036
{
    "columnNumber": 56,
    "lineNumber": 78,
    "fileName": "webpack:///src/store/entitys/entitys-reducer.js",
    "functionName": "getEntitysById"
}
{
    "columnNumber": 56,
    "lineNumber": 78,
    "fileName": "webpack:///src/store/entitys/entitys-reducer.js",
    "functionName": "map"
}
Still would be better to avoid this :)

T Crichton

unread,
Aug 5, 2019, 2:30:13 PM8/5/19
to ChromeDriver Users
Unfortunately, this feature doesn't exist at this time. 
As Chromium is an open source platform, possibly another developer would be interested in adding such a capability.

Carl Erik Kopseng

unread,
Aug 5, 2019, 4:47:02 PM8/5/19
to ChromeDriver Users
Thank you for your reply. Am I correct in my understanding of what you wrote, when I say that it is Chromium that lacks hooks for ChromeDriver to tap into?

Since this is a flag that used to be disabled by default in DevTools, and is now enabled in DevTools from version 39, one might be tempted in thinking that trying to expose a toggle flag through a command line switch or similar would be quite feasible. I haven't dabbled in C++ for years, though, so I'm not all that tempted right now :-)

I managed to scratch my itch using the `stackdriver-cli` tool I cobbled together, so it will have to do for now.

Regards
Reply all
Reply to author
Forward
0 new messages