Git Product home page Git Product logo

Comments (10)

pavelfeldman avatar pavelfeldman commented on June 19, 2024 1

awaitPromise can be only used once, while it might be handy to be able to call something repeatedly. I would say that using console.debug is the most pragmatic approach to address it atm.

from devtools-protocol.

dgozman avatar dgozman commented on June 19, 2024

Does Runtime.awaitPromise (or awaitPromise flag in Runtime.evaluate) help?

from devtools-protocol.

dgozman avatar dgozman commented on June 19, 2024

@aslushnikov who was hitting the same

from devtools-protocol.

samir-mahendra avatar samir-mahendra commented on June 19, 2024

awaitPromise helps in situations where the controlling process knows to expect a signal from the web context at some later time, and it's true that this handles most of the use cases PhantomJS's onCallback was used for.

Here's a use case where it won't work for us:

One application we are testing is a non-single page app, and has a page that, after on load, runs about 30K lines of Javascript (dynamically generated by server, so # of lines varies) in the HTML body before it's "ready" to check it's DOM. We initially handled testing it by waiting for the load Event and then timing out, but then under load test conditions, with the CPU pegged, the timeout was firing too early.

This application is being tested through a re-writing proxy, so in the proxy, we added a call to "callPhantom" after the last line of Javascript, like so:

// Existing JS
window.top.callPhantom({event: "readytotest"});
</script>

In PhantomJS, we then get a onCallback that tells us in a deterministic way that the page is loaded.

We're looking for something similar for Headless Chrome without using a 'console.log' and looking for it with a 'Runtime.consoleAPICalled' callback.

from devtools-protocol.

dgozman avatar dgozman commented on June 19, 2024

from devtools-protocol.

kensoh avatar kensoh commented on June 19, 2024

Hi @samir-mahendra I'm also using headless Chrome for web automation. At the moment I try to check for some changes in DOM as an indication that the script or some activity that is supposed to be done is ready.

It is probably not an elegant way to do it this way, but it closely resembles a user's behaviour when using the browser (click something, wait for something to visually appear, then do something else). So I use that approach.

from devtools-protocol.

mmuffins avatar mmuffins commented on June 19, 2024

Considering that the last message in this issue was written over a year ago - does anybody know if there were any updates related to this question?

I have a very similar use case where I want to react to a custom event, and the suggested workaround to inject some javascript that calls console.debug whenever the event is fired and listen to runtime.consoleAPICalled still seems like the best (and only) approach to do so, but it really feels more like a hack than a proper solution.

from devtools-protocol.

alexkozy avatar alexkozy commented on June 19, 2024

You may consider using Runtime.addBinding. As soon as binding called you will get Runtime.bindingCalled notification with string paylod.

from devtools-protocol.

mmuffins avatar mmuffins commented on June 19, 2024

I'll have a look at that, thanks a lot!

from devtools-protocol.

TimvdLippe avatar TimvdLippe commented on June 19, 2024

This repository is related to Chrome DevTools Protocol, but does not track issues regarding its definition or implementation. If you want to file an issue for the Chrome DevTools Protocol, please open an issue on https://crbug.com under component: Platform>DevTools>Platform. Thanks in advance!

from devtools-protocol.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.