I have learned programming asynchronous PhantomJS code, but now I am planning to write synchronous JavaScript. I have known promise can do this.
How can I write synchronous JavaScript code for PhantomJS?
I have learned programming asynchronous PhantomJS code, but now I am planning to write synchronous JavaScript. I have known promise can do this.
How can I write synchronous JavaScript code for PhantomJS?
I am planning to write synchronous JavaScript. I have known promise can do this.
That's not exactly true. Promises still require asynchronous programming, but they are good to escape the callback hell.
How can I write synchronous JavaScript code for PhantomJS?
The PhantomJS API uses callbacks to work. It doesn't emit promises that you can use. Of course you could write a wrapper around PhantomJS to support a promise-like API, but that would be overkill. Have a look at CasperJS which is built on top of PhantomJS (and Slimer.js) and does provide an API similar to the promise syntax, but there are differences. I have an answer that shows some intricacies of using CasperJS.