Blank Web Page with PhantomJS and CasperJS

Today, I was attempting to debug an issue where some of our functional tests were not running with the new React powered parts of WordPress.com.

As part of the debugging process, I decided to see if the tests would pass when run from my local machine instead of our test server. But, any time I ran a test, the test would fail.

madComputer

An Example Test

Here is part of the test that we use to test the log-in/log-out functionality on WordPress.com

[javascript]
casper.test.begin( ‘Can log in to WordPress’, function suite( test ) {
casper.start( ‘https://wordpress.com/’, function() {
test.assertExists( ‘.click-wpcom-login’, ‘Login link exists on front page when logged out’ );
} );

casper.run ( function() {
test.done();
} );
} );
[/javascript]

But, when I run this test, this is the output that I get:

[code]
# Can log in to WordPress
FAIL Login link exists on front page when logged out
# type: assertExists
# file: logging-in-out.js:3
# code: test.assertExists( ‘.click-wpcom-login’, ‘Login link exists on front page when logged out’ );
# subject: false
# selector: ".click-wpcom-login"
[/code]

To debug this test, I dumped the HTML to my terminal and got this: <html><head></head><body></body></html>

The Fix?

After searching a bit, I found this answer.

It seems that there was a mismatch between the version of TLS that WordPress.com uses and the version that PhantomJS uses.

I was able to get my test to work by changing the command to: casperjs test --ssl-protocol=any logging-in-out.js

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Eric Binnion

Subscribe now to keep reading and get access to the full archive.

Continue reading