In this recipe, we will introduce the
libraryPath property on the
phantom object and discuss how to use it to control the source of scripts that are loaded in the runtime via
To run this recipe, we will need at least one injectable script and the script that we want to run.
The script in this recipe is available in the downloadable code repository as
chapter02. If we run the provided example script, we must change to the root directory for the book's sample code.
Consider the following script:
console.log('Initial libraryPath: ' + phantom.libraryPath); phantom.libraryPath = phantom.libraryPath.replace(/chapter02$/, 'lib'); console.log('Updated libraryPath: ...