The phantom object

The phantom object is your reference to PhantomJS within your scripts that allows you to access certain properties and provides functionality that affects the entire script (such as quitting the application as previously mentioned.) The phantom object can be directly referenced anywhere in the script and does not need to be explicitly imported. You may also access it as a child of the global window object.

The phantom object allows access to relevant data, such as cookies and library paths. If we want to import or inject third-party JavaScript libraries, such as jQuery, we can do that using the phantom object. We can also create a "catch all" event handler for errors using the onError event of the phantom object.

PhantomJS not only allows us to harness the power of JavaScript but also gives us a very useful API. Each day, more and more contributors are enhancing this API, giving us more options and easier ways to solve real problems. We will learn more about these APIs as we continue our journey learning about PhantomJS.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.180.68