2016-09-05 7 views
0

私はnodejsサーバーを持っていますので、nightwatchでいくつかの機能テストを開始します。テストは実行されません - 標準mochaとphantomjsを使用したnightwatch

手動でセレンを起動し、mocha(コマンド:mocha ./test/functional/*.spec.js --compilers js:babel-register)で実行すると、ノードサーバーが起動し、firefoxで正常に動作しますデフォルト - 途中でそれが他のブラウザにデフォルトのFirefoxから変更することができますどのように標準モカを使用して):

import nightwatch from 'nightwatch'; 

require('../../server'); 

describe('Functional', function wrapIt() { 
    const client = nightwatch.initClient({ 
    silent: true, 
    }); 

    const browser = client.api(); 

    this.timeout(99999999); 

    beforeEach((done) => { 
    client.start(done); 
    }); 

    it('should login', (done) => { 
    browser 
     .url('http://localhost:8441/') 
     .waitForElementVisible('button[name=login]', 1000) 
     .click('button[name=login]') 
     .pause(1000); 

    browser.expect.element('button').to.have.attribute('class').which.contains('theme__button'); 
    browser.end(); 
    client.start(done); 
    }); 

    after((done) => { 
    browser.end(); 
    client.start(done); 
    }); 
}); 

今私はセレンサーバが起動し、竹の上に置くとphantomjsを使用すると、サーバが起動しnodejsけど?テストは実行されません。 私はnightwatch.jsonを持っている:

{ 
    "src_folders" : ["test/night"], 
    "output_folder": "reports", 
    "test_runner" : "mocha", 

    "selenium" : { 
    "start_process": true, 
    "server_path": ".//bin/selenium-server-standalone-2.53.1.jar", 
    "log_path": "./reports", 
    "host": "127.0.0.1", 
    "port": 4444 
    }, 

    "test_settings" : { 
    "default" : { 
     "desiredCapabilities": { 
     "browserName": "phantomjs", 
     "phantomjs.cli.args" : ["--ignore-ssl-errors=true"], 
     "version":"latest", 
     "javascriptEnabled": true, 
     "acceptSslCerts": true 
     } 
    } 
    } 
} 
nightwatch.conf.jsは次のとおりです。

require('babel-core/register'); 

module.exports = require('./nightwatch.json'); 

と夜フォルダ内のテスト・スクリプト:

require('../../server'); 

describe('Functional', function wrapIt() { 
    const client = this.client; 
    const browser = client.api(); 

    this.timeout(99999999); 

    beforeEach((done) => { 
    client.start(done); 
    }); 

    it('should login', (done) => { 
    browser 
     .url('http://localhost:8441/') 
     .waitForElementVisible('button[name=login]', 1000) 
     .click('button[name=login]') 
     .pause(1000); 

    browser.expect.element('button').to.have.attribute('class').which.contains('theme__button'); 
    browser.end(); 
    client.start(done); 
    }); 

    after((done) => { 
    browser.end(); 
    client.start(done); 
    }); 
}); 

ので、実行していますnightwatchでセレンサーバを起動し、nodejsサーバもokを開始しますが、何も起こりませんs。

+0

は、そのセレンサーバパス里です、それを起動するcommmandを追加しましたght?また、Bambooのログもありますか?彼らはあなたに問題を指摘するのに役立つかもしれません。 – reergymerej

答えて

0

私はwebdriverを使用して、それを変更:

export const client = require('webdriverjs').remote({ // eslint-disable-line 
    // Settings 
    desiredCapabilities: { 
    // You may choose other browsers 
    // http://code.google.com/p/selenium/wiki/DesiredCapabilities 
    browserName: 'phantomjs', 
    }, 
    // webdriverjs has a lot of output which is generally useless 
    // However, if anything goes wrong, remove this to see more details 
    logLevel: 'silent', 
}); 

client.init(); 

と:

require('../../server'); 

const client = require('./client').client; 

describe('Functional testing', function wrapIt() { 
    this.timeout(99999999); 

    before((done) => { 
    client.init().url('http://localhost:8441/', done); 
    }); 

    describe('Check homepage',() => { 
    it('should login', (done) => { 
     client.waitFor('button[name=login]', 100,() => { 
     client.click('button[name=login]',() => { 
      client.element('.theme__button*'); 
      client.waitForVisible(1000); 
      client.end(); 
     }); 
     }); 
     done(); 
    }); 
    }); 

    after((done) => { 
    client.end(); 
    done(); 
    }); 
}); 

をし、それがモカ」./test/funcTest.js' --compilersのJSを実行している作品:バベル登録-t 10000

PS:セレンはすでにローカルに開始され、竹の上に、私は

関連する問題