TypeError: undefined is not an object (evaluating 'phantomArgs.forEach')

628 views
Skip to first unread message

Sulthon Zainul Habib

unread,
Dec 20, 2015, 9:14:52 AM12/20/15
to CasperJS
I have problem, with CasperJS combine PhantomJS 2.0
TypeError: undefined is not an object (evaluating 'phantomArgs.forEach')


How fix, i have downloaded last update.
Have any solution?

Tim Scott

unread,
Dec 20, 2015, 10:27:39 AM12/20/15
to casp...@googlegroups.com
With PhantomJS 2.0 you need to use phantomjs-2 branch of casperjs.
--
CasperJS homepage & documentation: http://casperjs.org/
CasperJS @github: https://github.com/n1k0/casperjs
 
You received this message because you are subscribed to the Google Groups "casperjs" group.
Visit this group at http://groups.google.com/group/casperjs?hl=en.
---
You received this message because you are subscribed to the Google Groups "CasperJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to casperjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sulthon Zainul Habib

unread,
Dec 20, 2015, 10:53:04 AM12/20/15
to CasperJS
i have downloaded caperJS at https://github.com/n1k0/casperjs, but this problem not solved

Steve Nesbitt

unread,
Jan 6, 2016, 12:50:07 AM1/6/16
to CasperJS
I am also having the same issue on a Windows Server 2012.

My software versions are:

phantomJs: 2-0-0-windows
casperJs: 1-0-4

I have set the PATH environment variable to include E:\phantomJs;E:\phantomJS\bin;E\casperJs\batchbin\

I have created a sample.js file, as follows:

phantom.casperPath = 'E:\\CasperJs';
phantom
.injectJs(phantom.casperPath + '\\bin\\bootstrap.js');
var casper = require('casper').create();
casper
.start('http://casperjs.org/', function() {
   
this.echo(this.getTitle());
});
casper
.thenOpen('http://phantomjs.org', function() {
   
this.echo(this.getTitle());
});
casper
.run();


When I run the following command:

> phantomjs sample.js

I get the following error:

TypeError: undefined is not an object (evaluating 'phantomArgs.forEach;)
E:\CasperJs\bin\bootstrap.js:48 in global code


I have also tried running the sample.js using casperjs (as opposed to phantomjs). That is:

> casperjs sample.js

I get the following error:

Couldn't find nor compute phantom.casperPath, exiting.
E:\CasperJs\batchbin\..\bin\bootstrap.js:241 in loadCasper


Can anyone assist? I'm burning hours on this and not getting very far.

Thanks

Steve

unread,
Jan 6, 2016, 1:11:02 AM1/6/16
to CasperJS

Just stumbled on what I think is the fix. I trawled through github and saw a fix by goggelz entitled 'fixed phantom.args for phantomjs 2.x' (15924f8 on Feb 13, 2015).

The fix was in the casperjs\bin\bootstrap.js

I copied the following lines into my version of bootstrap.js from line 33:

if (!phantom) {
    console
.error('CasperJS needs to be executed in a PhantomJS environment http://phantomjs.org/');
} else {
   
if (phantom.version.major === 2) {
       
//setting other phantom.args if using phantomjs 2.x
       
var system = require('system');
       
var argsdeprecated = system.args;
        argsdeprecated
.shift();
        phantom
.args = argsdeprecated;
   
}
}

This at least allowed the sample.js to run successfully.

Hope this helps ...
Reply all
Reply to author
Forward
0 new messages