2017-11-02 17 views
2

私はJavaスクリプト分度器キュウリのフレームワークには初めてです。分度器テストは合格ですが、テストは実行しませんでした

1年前に同様の問題が発生しましたが、これは1年前の分度器リリースでも修正されています。新たな疑問が生まれる。

私はキュウリ、分度器、キュウリ骨格、チャイ、約束どおりの最新バージョンを使用しています。私はエディタとしてビジュアルスタジオコードを使用しています。 ノードのバージョンは6.11.4です。すべてのバージョンの詳細については、下記のpackage.jsonをご覧ください。

私がテストを実行すると、パスの結果が1秒未満で終了しますが、ブラウザを起動してブラウザで何もしません。

私が使用しているファイルを見て、どこに問題があるのか​​を教えてください。私はこれが最新の分度器のバスであるかどうかはわかりません。

protractor.conf.js:

exports.config = { 
    seleniumAddress: 'http://localhost:4444/wd/hub', 
    specs: ['features/*.feature'], 
    getPageTimeout: 60000, 
    allScriptsTimeout: 500000, 
    baseURL: 'http://www.protractortest.org/testapp/ng1/#/form', 
    framework: 'custom', 
    frameworkPath: require.resolve('protractor-cucumber-framework'), 
    capabilities: { 
     'browserName': 'chrome' 
    }, 
    cucumberOpts: { 
     require: [ './features/step_definitions/*.steps.js' ], 
     tags: false, 
     profile: false, 
     'no-source': true 
    } 
}; 

package.json:

{ 
    "name": "protractor_test", 
    "version": "1.0.0", 
    "description": "", 
    "main": "protractor.conf.js", 
    "dependencies": { 
    "protractor": "^5.2.0", 
    "cucumber": "^3.1.0", 
    "chai": "^4.1.2", 
    "chai-as-promised": "^7.1.1", 
    "@types/chai-as-promised": "^7.1.0", 
    "@types/cucumber": "^2.0.4", 
    "@types/protractor": "^4.0.0" 
    }, 
    "devDependencies": { 
    "protractor-cucumber-framework": "^4.1.1" 
    }, 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1" 
    }, 
    "author": "", 
    "license": "ISC" 
} 

test.feature:

Feature: Running Cucumber with Protractor 
    As a user of Protractor 
    I should be able to use Cucumber 
    In order to run my E2E tests 

    Scenario: Login to myApp 
     Given I go to Login page 
     When I login with "username" and "pwd" 
     Then "You are logged in as ADMIN" is displayed 

test.steps.js:

var chai = require('chai'); 
var chaiAsPromised = require('chai-as-promised'); 
var {defineSupportCode} = require('cucumber'); 
var expect = chai.expect; 
chai.use(chaiAsPromised); 
defineSupportCode(function({Given, When, Then}) { 
    Given('I go to DSH Login page', function() { 
     browser.get("http://localhost/myapp"); 
     expect(element(by.buttonText('Login')).isDisplayed()).to.eventually.equal(true); 
    }); 
    When('I login with {string} and {string}', function (username, password) { 
     element(by.id('username')).sendKeys(username); 
     element(by.id('password')).sendKeys(password); 
     element(by.buttonText('Login')).click(); 
    }); 
    Then('{string} is displayed', function (headerText) { 
     expect(element(by.cssContainingText('ng-isolate-scope', headerText)).isDisplayed()).to.eventually.equal(true); 
    }); 
}); 

コンソール出力:

Debugging with legacy protocol because Node.js v6.11.4 was detected. 
'C:\Program Files\nodejs\node.exe' --debug-brk=38084 --nolazy node_modules\protractor\bin\protractor protractor.conf.js 
Debugger listening on [::]:38084 
[16:48:02] I/launcher - Running 1 instances of WebDriver 
[16:48:02] I/hosted - Using the selenium server at http://localhost:4444/wd/hub 
... 
1 scenario (1 passed) 
3 steps (3 passed) 
0m00.015s 
[16:48:05] I/launcher - 0 instance(s) of WebDriver still running 
[16:48:05] I/launcher - chrome #01 passed 

セレンクロムノードコンソール出力:

Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 11099 
Only local connections are allowed. 
16:48:04.496 INFO - Found handler: [email protected] 
16:48:04.496 INFO - Handler thread for session ed9fb79d586bc77176974953aaf98ef2 (chrome): Executing POST on /session/ed9fb79d586bc77176974953aaf98ef2/timeouts (handler: ServicedSession) 
16:48:04.496 INFO - To upstream: {"script":500000} 
16:48:04.496 INFO - To downstream: {"sessionId":"ed9fb79d586bc77176974953aaf98ef2","status":13,"value":{"message":"unknown error: 'ms' must be a double\n (Session info: chrome=60.0.3112.78)\n (Driver info: chromedriver=2.33.506120 (e3e 
53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.3.9600 x86_64)"}} 
16:48:04.512 INFO - Found handler: [email protected] 
16:48:04.512 INFO - Handler thread for session ed9fb79d586bc77176974953aaf98ef2 (chrome): Executing POST on /session/ed9fb79d586bc77176974953aaf98ef2/timeouts (handler: ServicedSession) 
16:48:04.512 INFO - To upstream: {"type":"script","ms":500000} 
16:48:04.527 INFO - To downstream: {"sessionId":"ed9fb79d586bc77176974953aaf98ef2","status":0,"value":null} 
16:48:05.010 INFO - Found handler: org.ope[email protected] 
16:48:05.010 INFO - Found handler: [email protected] 
16:48:05.010 INFO - Handler thread for session ed9fb79d586bc77176974953aaf98ef2 (chrome): Executing DELETE on /session/ed9fb79d586bc77176974953aaf98ef2 (handler: ServicedSession) 
16:48:05.010 INFO - Handler thread for session ed9fb79d586bc77176974953aaf98ef2 (chrome): Executing POST on /session/ed9fb79d586bc77176974953aaf98ef2/url (handler: ServicedSession) 
16:48:05.026 INFO - To upstream: {"url":"data:text/html,<html></html>"} 
16:48:05.088 INFO - To downstream: {"sessionId":"ed9fb79d586bc77176974953aaf98ef2","status":0,"value":null} 
16:48:05.088 INFO - Removing session [email protected] 
16:48:05.138 INFO - To downstream: {"sessionId":"","status":0,"value":null} 
16:48:05.138 INFO - To downstream: {"sessionId":"","status":6,"value":{"message":"no such session\n (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.3.9600 x86_64)"}} 

答えて

7

はあなたがコールバック引数の代わりを使用して試すことができます約束に頼って。それが動作すれば、ユーザー名&を入力するために、Qパッケージを使用してすべての約束を解決することができます。

var chai = require('chai'); 
var chaiAsPromised = require('chai-as-promised'); 
var {defineSupportCode} = require('cucumber'); 
var expect = chai.expect; 
chai.use(chaiAsPromised); 
defineSupportCode(function({Given, When, Then}) { 
    Given('I go to DSH Login page', function (callback) { 
     browser.get("http://localhost/myapp"); 
     expect(element(by.buttonText('Login')).isDisplayed()).to.eventually.equal(true).and.notify(callback); 
    }); 
    When('I login with {string} and {string}', function (username, password, callback) { 
     element(by.id('username')).sendKeys(username); 
     element(by.id('password')).sendKeys(password); 
     element(by.buttonText('Login')).click().then(function() { 
      callback(); 
     }); 
    }); 
    Then('{string} is displayed', function (headerText, callback) { 
     expect(element(by.cssContainingText('ng-isolate-scope', headerText)).isDisplayed()).to.eventually.equal(true).notify(callback); 
    }); 
}); 
+0

ありがとうございます。それは問題を解決した。 – Navin

関連する問題