Chromeless: Implement an onConsoleMessage() event

Created on 9 Aug 2017  路  6Comments  路  Source: prisma-archive/chromeless

```javascript
.evaluate(() => {
console.log('aaaa') // Could console be effected in function 'evaluate() '
})

feature help wanted question

Most helpful comment

Actually Console is deprecated, use Log.entryAdded (_experimental_) or Runtime.consoleAPICalled instead.

All 6 comments

Yes.

evaluate(): Evaluate Javascript code within Chrome in the context of the DOM.

You can access anything you normally would be able to via script injected on the page, because that's what's being done here. The method you pass to evaluate() is serialized, injected into the page, and then executed.

Yes, I know. I think if there is a method to catch the log executed in the page.
javascript chromeless.evaluate(() => { $("button").click(); console.info($("button")) }); chromeless.onConsoleMessage=(msg) => { console.log(msg); };//a method to catch the log executed in the page.

I see. Yes, that would be nice. I've wanted that too.

I guess what you're looking for is access to Console.messageAdded?

Actually Console is deprecated, use Log.entryAdded (_experimental_) or Runtime.consoleAPICalled instead.

Hi, is there a clean way to get the client (CDP) from chromeless instance?

just wanna do like this...

const chromeless = new Chromeless()

const client = ? // o.o?

const { Runtime } = client
Runtime.consoleAPICalled(({ type, args }) => {
  console[type].apply(console, args.map(o => o.value))
})
Was this page helpful?
0 / 5 - 0 ratings

Related issues

schickling picture schickling  路  3Comments

adieuadieu picture adieuadieu  路  3Comments

schickling picture schickling  路  5Comments

vanloc0301 picture vanloc0301  路  4Comments

eitansela picture eitansela  路  4Comments