user1921925
user1921925

Reputation: 41

PhantomJS; Install and Running Examples

I am new to PhantomJS and to JavaScript. My question is very basic, but it has been giving me a lot of difficulty.

I have successfully added the PATH of the executable file to my system variables and when I type "phantomjs --version" into the command prompt, the correct version (1.7.0) is displayed.

However, when I try testing one of the examples, for instance hello.js, I receive the following message "Can't find variable: hello"

Originally I kept the examples files in the folder "examples" but have also tried moving them to the main phantomjs folder, where the executable file resides. Neither option works.

I also tried opening the examples using the following statement, from the command prompt: "phantomjs examples/hello.js" and I received the following statement "Can't open 'examples/hello.js'".

I know there have been a few other similar questions regarding this on the forum, but the solutions have not worked for me. Any fresh advice would be great, thanks!

Upvotes: 4

Views: 2959

Answers (2)

Lex Podgorny
Lex Podgorny

Reputation: 2930

Was having the same trouble. Finally solved it by specifying absolute path to phatnomjs executable.

instead of:

phantomjs myjsfile.js

do:

/my/absolute/path/to/phantomjs/phantomjs myjsfile.js

I suspect setting up PATH to it will have the same effect, have not tested it though.

Upvotes: 1

Ariya Hidayat
Ariya Hidayat

Reputation: 12561

Assuming hello.js file is in your current working directory, you need to type:

phantomjs hello.js

in your terminal or command prompt, and not in PhantomJS prompt.

Upvotes: 1

Related Questions