私のアプリケーションは、felixサーバー上で実行されているosgi-modelに基づいています。 GUIはAngularです。 私はバックエンド開発者と並行してGUIテストを開発しています。多くのGUIスクリーンはまだ実装されていないので、GUI機能をテストするために分度器を使用するのが早いです。AngularJs-e2e分度器でテスト:websocket経由でサーバーに接続する方法
しかし、私は "gui beying"とし、フェリックス経由でいくつかのイベントを送受信したいと思います。このようにして、フロントエンドによって起動される主要な既知のバックエンド機能をテストできます。
しかし、フェリックスサーバーにイベントを送信する方法がわかりません!私はfelix-serverへのwebsocket接続を開き、それにイベントを送ります。
//cucumConfig.js
'use strict';
exports.config = {
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
getPageTimeout: 60000,
allScriptsTimeout: 500000,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
output:'./output.json',
capabilities: {
'browserName': 'chrome'
},
specs: [
'*.feature'
],
cucumberOpts: {
require: '*_steps.js',
tags: false,
format: 'pretty',
profile: false
},
};
:これは私のcucmber-構成です
//home_steps.js
var websocketOnFelix = require ('./websocket2Felix.js');
var homeSteps = function() {
this.Given(/^I am on the home$/, function() {
browser.get("path/to/home");
});
this.When(/^I click on help button$/, function(){
//open websocket to felix to send gui-events to it
browser.pause();
websocketOnFelix.openConnection();
browser.pause();
/////// here to send the click event to felix//////
});
this.Then(/^The help screen should be displayed$/, function(){
el= element(by.css('#help-screen'));
expect(el.isPresent()).to.be.ok;
});
});
:私はキュウリの構文を使用して書いた私のテスト・ケースの定義、このコードを使用し
//websocket2Felix.js
var websocket =null;
module.exports = {
openConnection: function() {
try{
websocket = new WebSocket("ws://localhost:8080/myproj");
websocket.onopen = function(evt) { onOpen(evt) };
websocket.onclose = function(evt) { onClose(evt) };
websocket.onmessage = function(evt) { onMessage(evt) };
websocket.onerror = function(evt) { onError(evt) };
}
catch(err){
browser.logger.info(err.message + "/n");
}
},
doSend: function(message) {
browser.logger.info("SENT: " + message);
websocket.send(message);
}
};
function onOpen(evt) {
}
function onClose(evt) {
}
function onMessage(evt) {
}
function onError(evt) {
}
:ここに私のコードです私は呼ん
protractor cucumbConfig.js
この行の後に "websocketOnFelix.openConnection();"私はテストケースの次の行に到達することは決してありません。
のtry-catchブロックを追加した後、エラーがライン
websocket = new WebSocket(...);
からarisedです: "のWebSocketが定義されていません"。
私は間違っていますか? ありがとうございます。
WebSocketパッケージを使用する前にインストールしました。私は問題が、同類の非同期/非同期のコミュニケーションの何かであると思います。 – saab