Tag Archives: phantomjs

Phantomjs and testem

I ran into this problem with Testem not picking up phantomjs from the command line to run the tests.

My testem.json

{
“launch_in_dev”: [
“phantomjs”
]

}

The problem

npm folder where the installs occur for globals was still owned by root.

If I tried to run phantomjs from the command line it would throw up a stack trace about ownership.

The solution Chown

sudo chown -R the location where the global node modules are installed by npm.

OSX

sudo chown -R YOURUSER:YOURGROUP /usr/local/lib/node_modules/

Linux

sudo chown -R YOURUSER:YOURGROUP /usr/lib/node_modules/

Advertisements

Phantomjs cannot be started and local install

Do not put phantomjs in your package.json of your node project.

When you call npm install it will install the package locally in your project’s node_modules folder.

When you try and run grunt test you will get an error message similar to this.

phantomjs cannot be started.

Fixing local phantomjs install

rm node_modules

npm install

Phantomjs must be installed globally.

npm install -g phantomjs

PhantomjsDriver Geb with Jquery click events throwing error workaround

When moving to phantomjs from using Geb with a browser you will find that some click events do not fire and give you an error.  I have not investigated this thoroughly on what works and what fails.

Tested Config:
Geb: 0.6.3
Phantomjs: 1.9.1
Jquery: 1.7.1
phantomjsdriver: 1.0.4

The problem I had was   $(“.SUBMIT_BUTTON”).click() will not always work and give you the following error:

Error: cannot access member `resetOneShotCallbacks’ of deleted QObject

:/ghostdriver/session.js:197
:/ghostdriver/session.js:227

Continue reading

Groovy with Geb using Phantomjs and ssl certs

Here is my setup for using self signed certs and allowing the PhantomJsDriver to use Phantomjs and hit https pages while using self signed certificates.

Read Tomás Lin’s excellent post on setting up Geb with Phantomjs.

http://fbflex.wordpress.com/2013/03/18/how-to-configure-webdriver-in-grails-for-your-geb-tests/

The phantomjsdriver will producde a log file phantomjsdriver.log when creating the instance of phantomjs.

Negotiated Capabilities: {“browserName”:”phantomjs”,”version”:”1.9.1″,”driverName”:”ghostdriver”,”driverVersion”:”1.0.3″,”platform”:”mac-10.8 (Mountain Lion)-32bit”,”javascriptEnabled”:true,”takesScreenshot”:true,”handlesAlerts”:false,”databaseEnabled”:false,”locationContextEnabled”:false,”applicationCacheEnabled”:false,”browserConnectionEnabled”:false,”cssSelectorsEnabled”:true,”webStorageEnabled”:false,”rotatable”:false,“acceptSslCerts”:false,”nativeEvents”:true,”proxy”:{“proxyType”:”direct”}}

AcceptSslCerts is shown as false in the log, but the below code will use command line arguments to force phantomjs to accept any certificate.  The value we are most interested in is –ignore-ssl-errors=true

https://github.com/ariya/phantomjs/wiki/API-Reference

Continue reading