I am currently using webdriverjs to run automated tests on a Windows 8 system. The tests run successfully when the browser is set to Chrome, but encounter issues when I switch to PhantomJS. Interestingly, the same tests run smoothly on OS X Mavericks.
Instead of failing, the tests seem to wait indefinitely without any progress.
This is where the client is defined in the file:
exports.client = require('webdriverjs').remote({
desiredCapabilities: {
browserName: 'phantomjs'
}
});
Furthermore, this file contains my test script:
var chai = require('chai'),
assert = chai.assert,
expect = chai.expect,
webdriverjs = require('webdriverjs'),
client = require('./client').client;
describe('my webdriverjs tests', function(){
this.timeout(10000);
before(function(done){
client.init(done);
});
it('Github test',function(done) {
client
.url('https://github.com/')
.getElementSize('.header-logo-wordmark', function(err, result) {
assert.equal(null, err);
assert.strictEqual(result.height , 32);
assert.strictEqual(result.width, 89);
})
.getTitle(function(err, title) {
assert.equal(null, err);
assert.strictEqual(title,'GitHub · Build software better, together.');
})
.getCssProperty('a[href="/plans"]', 'color', function(err, result){
assert.equal(null, err);
assert.strictEqual(result, 'rgba(65,131,196,1)');
})
.call(done);
});
after(function(done) {
client.end(done);
});
});
I have installed mocha, selenium-standalone, phantomjs NPM packages globally, and webdriverjs as well as chai in the project directory.
To start selenium, I use the start-selenium
command, and then execute the test with mocha test.js
.
Despite not encountering any failures, the test just hangs with a blinking cursor until I manually stop it.
Here is the output from selenium:
c:\Code\cie-teacher-support-portal-web\src\CIE.TeacherSupportPortal.Web>start-selenium
Jun 10, 2014 10:33:18 AM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
Setting system property webdriver.chrome.driver to C:\Users\Alex Cason\AppData\Roaming\npm\node_modules\selenium-standalone\.selenium\2.42.0\chromedriver
10:33:18.788 INFO - Java: Oracle Corporation 21.0-b17
10:33:18.789 INFO - OS: Windows NT (unknown) 6.2 amd64
10:33:18.820 INFO - v2.42.0, with Core v2.42.0. Built from revision 5e82430
10:33:18.935 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
... (output continues)