Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: expose URL and line number for ConsoleMessage object #3029

Closed
stereobooster opened this issue Aug 6, 2018 · 10 comments
Closed
Labels
chromium Issues with Puppeteer-Chromium feature good first issue

Comments

@stereobooster
Copy link

LogEntry object provides url and lineNumber

url: string - URL of the resource if known.
lineNumber: integer - Line number in the resource.

can we also expose it?

Related source https://github.com/GoogleChrome/puppeteer/blob/25632133e2683c613c97d9088968c48e3c07a086/lib/Page.js#L167-L173

@stereobooster stereobooster changed the title Feature request: expose URL and line number for ConsoleMessage object. Feature request: expose URL and line number for ConsoleMessage object Aug 6, 2018
@aslushnikov
Copy link
Contributor

@stereobooster sure, that's possible. Would you mind sharing a story why would you need this?

@stereobooster
Copy link
Author

stereobooster commented Aug 7, 2018

I see some console logs in the output, I want to track where they were called. It is not always trivial to do. https://github.com/stereobooster/react-snap is the tool I'm working on

@aslushnikov
Copy link
Contributor

Reasonable.

@andrew-st-angelo-77media
Copy link

andrew-st-angelo-77media commented Aug 30, 2018

Would this be the same information given to the right of each console item, in DevTools, identifying the calling resource and the line number (eg. application.min.js:13)? If so, that would be very useful.

@aslushnikov
Copy link
Contributor

@andrew-st-angelo-77media yeah that would be it.

@silent-lad
Copy link
Contributor

Can i work on this issue if no one is working on it ? @aslushnikov

@aslushnikov
Copy link
Contributor

@silent-lad please go ahead

@tompere
Copy link
Contributor

tompere commented Oct 8, 2018

@stereobooster - I've created a pull request to support the above.

a few notes:

  • I added additionalInfo method to ConsoleMessage under which lineNumber and url can be found. This is under the assumption that additionalInfo is a subset of LogEntry optional params, thus future requests for additional data can easily added.
  • I could not reproduce a test (nor local) use-case where console message (Log.entryAdded event) is returned with actual lineNumber. Moreover, I could reproduce a violation log entry in devtools, with line number and url (e.g. invoking document.write()), yet the same page didn't returned that value when using puppeteer or a 3rd party client I used to work with RDP.

tompere added a commit to tompere/puppeteer that referenced this issue Oct 11, 2018
This patch add additional method to ConsoleMessage object sent on console event. Currently, added URL and line number to additionalInfo.

Fixes puppeteer#3029
tompere added a commit to tompere/puppeteer that referenced this issue Oct 17, 2018
This patch add additional method to ConsoleMessage object sent on console event. Currently, added URL and line number to additionalInfo.

Fixes puppeteer#3029
@aslushnikov aslushnikov added the chromium Issues with Puppeteer-Chromium label Dec 6, 2018
@tharun208
Copy link

Is this issue is closed or I can start working on this ?

@stereobooster
Copy link
Author

there is #3365

aslushnikov pushed a commit that referenced this issue Jan 11, 2019
This patch adds a new consoleMessage.location() method that returns console message origins.

Fixes #3029
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chromium Issues with Puppeteer-Chromium feature good first issue
Projects
None yet
Development

No branches or pull requests

7 participants
@stereobooster @aslushnikov @tompere @tharun208 @silent-lad @andrew-st-angelo-77media and others