bslatkin / dpxdt

Make continuous deployment safe by comparing before and after webpage screenshots for each release. Depicted shows when any visual, perceptual differences are found. This is the ultimate, automated end-to-end test.
https://dpxdt-test.appspot.com
Apache License 2.0
1.44k stars 124 forks source link

capturing ajax based pages #77

Closed theincredibleguy closed 10 years ago

theincredibleguy commented 10 years ago

is there a way to introduce a delay parameter, which makes the tool wait for x milliseconds after loading the page(to finish ajax loading) and then take snapshot?

bslatkin commented 10 years ago

@theincredibleguy If there are AJAX requests that are still pending when the page loads the capture script should correctly wait for them before taking the snapshot. The logic is defined here:

https://github.com/bslatkin/dpxdt/blob/master/dpxdt/client/capture.js#L273

The gist of it is while any resources are still outstanding with no final status, the page will keep waiting. Once everything finishes it will wait another 500ms and then take the screenshot.

theincredibleguy commented 10 years ago

@bslatkin thanks a lot, not only for responding but also pointing me to the code which does the capturing. I tried altering the timeout values, but i cannot still capture the final snapshot of the screen. The page generally takes a loading time of 5 to 7 seconds to load. Also, the part you pointed me to, uses a variable resourceStatusMap; is there a way to debug the code to see the console messages to view the contents of resourceStatusMap?

bslatkin commented 10 years ago

@theincredibleguy Yes the output console logs from Phantom are available on the single "run" page in dpxdt and should say what the page is still waiting for. If you could grab those logs and send them to me I should be able to help you debug. I've tested this AJAX waiting code with a few other sites and it works well so I'm curious how your page is different.

bslatkin commented 10 years ago

Thanks for the log. Is the AJAX request fired during the DOM ready event? What actually fires off that AJAX request? Which script? If it loads in an async script, then the page won't be considered done until that async script loads and runs. If the injectedJS clicks a button that causes the AJAX load and capture.js should keep waiting. I'm trying to understand how this situation could arise. Is there some timeout/delay before the AJAX request is kicked off? Is there any way to get it to happen sooner with config.injectJs?

theincredibleguy commented 10 years ago

there's no specific DOM event on which charts load. As it turns out, now the snapshots are showing the charts, however the reasons are still unknown for prior behavior. Thanks a lot for your assistance on this :)

bslatkin commented 10 years ago

Okay let me know if you see it not work. I'm not sure how it would be possible unless there's a timer on load.