WebdriverJS tests freeze when using PhantomJS on Windows

I use webdriverjs to run automatic tests on Windows 8. Tests work correctly when I install the browser in Chrome, but not when I use PhantomJS. The same tests also work correctly when I run them on OS X Mavericks.

Tests fail, they just wait indefinitely.

Here is the file in which the client is defined:

exports.client = require('webdriverjs').remote({
  desiredCapabilities: {
    browserName: 'phantomjs'
  }
});

Here is the file containing my test:

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 mocha, selenium autonomous and phantomjs NPM packages installed globally, with webdriverjs and chai installed in the project directory.

I run selenium with the command start-seleniumand then run my test with mocha test.js.

As already mentioned, the test fails, it just waits for the blinking cursor until I make it exit.

:

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
10:33:18.937 INFO - Version Jetty/5.1.x
10:33:18.937 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
10:33:18.938 INFO - Started HttpContext[/selenium-server,/selenium-server]
10:33:18.938 INFO - Started HttpContext[/,/]
10:33:18.983 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@4672b784
10:33:18.983 INFO - Started HttpContext[/wd,/wd]
10:33:18.986 INFO - Started SocketListener on 0.0.0.0:4444
10:33:18.986 INFO - Started org.openqa.jetty.jetty.Server@3bba1558
10:33:25.692 INFO - Executing: [new session: Capabilities [{platform=ANY, javascriptEnabled=true, browserName=phantomjs, version=}]])
10:33:25.707 INFO - Creating a new session for Capabilities [{platform=ANY, javascriptEnabled=true, browserName=phantomjs, version=}]
10:33:25.721 INFO - executable: C:\Users\Alex Cason\AppData\Roaming\npm\phantomjs
10:33:25.722 INFO - port: 32714
10:33:25.722 INFO - arguments: [--webdriver=32714, --webdriver-logfile=c:\Code\cie-teacher-support-portal-web\src\CIE.TeacherSupportPortal.Web\phantomjsdriver.log]
10:33:25.723 INFO - environment: {}
+4
1

Ghostdriver Selenium:

(1) Selenium :

java -jar selenium-server-standalone-2.42.2.jar -role hub

(2) phantomjs/ghostdriver

phantomjs --webdriver=4445 --webdriver-selenium-grid-hub=http://127.0.0.1:4444

open webdriverjs, Selenium.

+2

Source: https://habr.com/ru/post/1543971/


All Articles