Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phantom js returns 'can't open [file name]' when trying to run example js file

Environment: Windows 7, Phantomjs version 1.8.0.

I try to run any .js file from 'examples' folder, installed Phantom.js before, added path to the PATH variable, checked version like

phantomjs --version

and it works.

But when I try to run

phantomjs examples/version.js

then get 'Can't open version.js'

I've checked file security settings and run cmd like administrator, but still the same result.

I'll appreciate any help to solve this issue. Thanks in advance.

like image 504
Artem Avatar asked Dec 26 '12 13:12

Artem


People also ask

How do I run PhantomJS?

For Windows Download the zip file, unpack it and you will get an executable phantom.exe. Set the PATH environment variable to the path of phantom.exe file. Open a new command prompt and type phantomjs –v. It should give you the current version of PhantomJS that is running.

How do you debug a test in PhantomJS?

Open a new browser tab and return to the debugging portal at http://127.0.0.1:9000. There should now be a second entry in the bulleted list. Click on this entry to open a new debugger that operates in the context of your page inside PhantomJS.

What is the use of PhantomJS?

PhantomJS is a discontinued headless browser used for automating web page interaction. PhantomJS provides a JavaScript API enabling automated navigation, screenshots, user behavior and assertions making it a common tool used to run browser-based unit tests in a headless system like a continuous integration environment.


2 Answers

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.

like image 93
Lex Avatar answered Oct 14 '22 02:10

Lex


In my case,

/mypath/phantomjs /mypath/myfile.js

It takes three days for finding this out. Pretty wired syntax to me.

If it doesn't work then use . in front of first /

    ./mypath/phantomjs ./mypath/myfile.js

. means base dir as you set in the R studio

like image 22
randomwalk1225 Avatar answered Oct 14 '22 01:10

randomwalk1225