Comments (10)
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.
Does Runtime.awaitPromise (or awaitPromise flag in Runtime.evaluate) help?
from devtools-protocol.
@aslushnikov who was hitting the same
from devtools-protocol.
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.
from devtools-protocol.
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.
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.
You may consider using Runtime.addBinding
. As soon as binding called you will get Runtime.bindingCalled
notification with string paylod.
from devtools-protocol.
I'll have a look at that, thanks a lot!
from devtools-protocol.
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)
- Target.createBrowserContext return error: Not allowed HOT 1
- Potential outdated definition for "Profiler.start"
- Inverse visualisation of diff in changelog.md HOT 1
- Method names not available HOT 2
- "Getting started" and "Basics" in the documentation not working HOT 2
- Consider adding "default" field to JSON schema property definitions.
- Facebook issue
- Page.compilationCacheProduced references non-existent Page.setGenerateCompilationCache
- "follwing" should be "following"
- Failed connecting to ws server ws://localhost:4444/devtools/... HOT 2
- Discrepencies in `dependencies` in multiple places
- No way to find the active tab HOT 1
- Reconsider versioning scheme
- It's not clear what kind of protocol is HOT 1
- Google Chrome
- How to interact with Chrome dialogs? HOT 1
- Enabling "Preserve Log" in Chrome Developer Tools Console via Selenium
- How to stream responses when using Fetch.fulfillRequest
- How to get a stream using Page.printToPDF method?
- Missing information on target types and their supported domains
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from devtools-protocol.