Транспортир с огурцом - сценарий не вызывается - PullRequest
0 голосов
/ 30 июня 2019

Мы новички в использовании Protractor, перейдя по ссылке ниже, чтобы попробовать настройку теста.http://maushamgupta.blogspot.com/2016/09/getting-started-with-protractor-cucumber.html

Ниже приведен файл conf (названный protractor.conf.js).

var config;
config = {

    //chromeDriver:'path\\to\\your\\chromedriver.exe',
    //seleniumArgs: ['-Dwebdriver.ie.driver=path\\to\\your\\IEDriverServer.exe'], //incase you want to test your application on internet explorer
    seleniumAddress: 'http://127.0.0.1:4444/wd/hub',

    specs: 'testwithpro.feature',

    capabilities: {
          browserName: 'chrome'
       },

    framework: 'custom', // need to add for protractor 3.x and above
    frameworkPath: './node_modules/protractor-cucumber-framework',  // need to add for protractor 
    output:'./output.json',                                                                          //3.x and above

    cucumberOpts: {
          // define your step definitions in this file
          require: ['./testwithpro.js'],
          //format: './node_modules/pretty',
          tags:'false'
       }
};

exports.config = config;

testwithpro.feature

Добавление: тестирование приложения

Сценарий: проверка входа в систему. Я нахожусь на странице входа в систему. Когда я ввожу имя пользователя и ввожу пароль, и я нажимаю кнопку входа в систему, то я должен увидеть домашнюю страницу

testwithpro.js

var myStepDefinitionsWrapper = function () {

this.Given(/^I am on the login page$/, function (callback) {

  // Write code here that turns the phrase above into concrete actions

  console.log('testing');
  browser.ignoreSynchronization=true; // To be added if the application is non-angular
  browser.driver.manage().window().maximize(); // To maximize the window
  //browser.get("https://www.facebook.com").then(function(){
  //  callback(); // To tell the cucumber that we are done with this step
  //})

            browser.get("https://www.facebook.com");
        browser.wait(function () {
        browser.sleep(10000);
        callback(); // To tell the cucumber that we are done with this step
        }, 20 * 10000);



});

this.When(/^I enter username$/, function (callback) {
  // Write code here that turns the phrase above into concrete actions
element(by.id("email")).sendKeys("abc@gmail.com").then(function(){
  callback();
 });
});

this.When(/^I enter password$/, function (callback) {
  // Write code here that turns the phrase above into concrete actions
  element(by.id("pass")).sendKeys("*****").then(function(){
  callback();
 });
});

this.When(/^I click on login button$/, function (callback) {
  // Write code here that turns the phrase above into concrete actions 
  element(by.id("u_0_l")).click().then(function(){
  callback();
 });
});

};
module.exports = myStepDefinitionsWrapper;

package.json (транспортир-огурец-каркас)

"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"chai-like": "^0.2.14",
"eslint": "^5.4.0",
"eslint-config-prettier": "^3.0.1",
"eslint-plugin-mocha": "^5.2.0",
"eslint-plugin-prettier": "^2.6.2",
"express": "^4.16.3",
"httpster": "^1.0.4",
"mocha": "^5.2.0",
"multidep": "2.0.2",
"prettier": "^1.14.2",
"protractor": "^5.4.0"

package.json (транспортир)

"зависимости": {"@ types / q": "^ 0.0.32","@ types / selenium-webdriver": "^ 3.0.0", "blocking-proxy": "^ 1.0.0", "browserstack": "^ 1.5.1", "chalk": "^ 1.1.3", "glob": "^ 7.0.3", "jasmine": "2.8.0", "jasminewd2": "^ 2.1.0", "optimist": "~ 0.6.0", "q": "1.4.1 "," saucelabs ":" ^ 1.5.0 "," selenium-webdriver ":" 3.6.0 "," source-map-support ":" ~ 0.4.0 "," webdriver-js-extender ":"2.1.0", "webdriver-manager": "^ 12.0.6"}, "не рекомендуется": false, "description": "Тестовая оболочка Webdriver E2E для Angular.", "DevDependencies": {"@ types / chalk":" ^ 0.4.28 "," @types / glob ":" ^ 5.0.29 "," @ types / jasmine ":" ^ 2.5.47 "," @ types / jasminewd2 ":" ^ 2.0.0 "," @ types / minimatch ":" ^ 2.0.28 "," @ types / minimist ":" ^ 1.1.28 "," @ types / node ":" ^ 6.0.46 "," @ types / optimist ":" ^ 0.0.29 "," body-parser":" ~ 1.15.2 "," chai ":" ~ 3.5.0 "," chai-as-обещано ":" ~ 5.3.0 "," clang-format ":" 1.0.49 "," ожидайте.js ":" ~ 0.3.1 "," express ":" ~ 4.14.0 "," gulp ":" ^ 3.9.1 "," gulp-clang-format ":" 1.0.23 "," gulp-tslint":" ^ 7.0.1 "," jshint ":" ^ 2.9.2 "," lodash ":" ^ 4.5.1 "," отмечены ":" ^ 0.3.3 "," mocha ":" 2.5.3"," rimraf ":" ~ 2.5.3 "," последовательность выполнения ":" ^ 1.1.5 "," semver ":" ^ 5.3.0 "," tslint ":" ^ 4.1.1 "," tslint-eslint-rules ":« ^ 3.1.0 »,« typcript »:« ^ 2.1.5 »,« vrsource-tslint-rules »:« ^ 4.0.1 »},

package.json (огурец)

"зависимости": {"@ babel / polyfill": "^ 7.2.3", "assertion-error-formatter": "^ 2.0.1", "bluebird": "^ 3.4.1 "," cli-table3 ":" ^ 0.5.1 "," colors ":" ^ 1.1.2 "," commander ":" ^ 2.9.0 "," cross-spawn ":" ^ 6.0.5 ", "cucumber-expressions": "^ 6.0.0", "cucumber-tag-expression": "^ 1.1.1", "duration ":" ^ 0.2.1 "," escape-string-regexp ":" ^ 1.0.5 "," figure ":" 2.0.0 "," gherkin ":" ^ 5.0.0 "," glob ":"^ 7.1.3", "indent-string": "^ 3.1.0", "is-generator": "^ 1.0.2", "is-stream": "^ 1.1.0", "knuth-shuffle-seeded ":" ^ 1.0.6 "," lodash ":" ^ 4.17.10 "," mz ":" ^ 2.4.0 "," progress ":" ^ 2.0.0 "," resol ":" ^1.3.3 "," serialize-error ":" ^ 3.0.0 "," stack-chain ":" ^ 2.0.0 "," stacktrace-js ":" ^ 2.0.0 "," string-argv ":«0.1.1», «case-case»: «^ 2.1.1», «util-arity»: «^ 1.0.2», «verror»: «^ 1.9.0»}, «не рекомендуется»: false,"description": "Официальная реализация JavaScript Cucumber.", "devDependencies": {"@ babel / cli": "^ 7.2.3", "@ babel / core": "^ 7.2.2", "@babel/ plugin-offer-function-bind ":" ^ 7.2.0 "," @ babel / preset-env ":" ^ 7.2.3 "," @ babel / register ":" ^ 7.0.0 "," ansi-html ":" ^ 0.0.7 "," babel-eslint ":" ^ 10.0.1 "," babel-plugin-istanbul ":" ^ 5.1.0 "," babelify ":" ^ 10.0.0 ","browserify ":" 16.2.2 "," chai ":" ^ 4.0.1 "," coffee-script ":" ^ 1.10.0 "," connect ":" ^ 3.4.0 "," coveralls ":" ^3.0.0 "," dependency-lint ":" ^ 5.0.1 ","eslint ":" ^ 5.10.0 "," eslint-config-prettier ":" ^ 3.3.0 "," eslint-config-standard ":" ^ 12.0.0 "," eslint-plugin-babel ":" ^5.3.0 "," eslint-plugin-import ":" ^ 2.14.0 "," eslint-plugin-node ":" ^ 8.0.0 "," eslint-plugin-prettier ":" ^ 3.0.0 ","eslint-plugin-обещание": "^ 4.0.1", "eslint-plugin-standard": "^ 4.0.0", "fs-extra": "^ 6.0.1", "mocha": "^ 5.2.0 "," усы ":" ^ 2.3.0 "," nyc ":" ^ 12.0.2 "," красивее ":" ^ 1.5.2 ","serve-static": "^ 1.10.0", "sinon": "^ 6.0.0", "синон-чай": "^ 3.2.0", "поток в строку": "^ 1.1.0", "tmp": "^ 0.0.33" },

Когда мы запускаем cmd «protractor protractor.conf.js», вывод в терминале будет таким:

[23:02:58] I / launcher - Запуск 1 экземпляра WebDriver [23:02:58] I / hosted - Использование сервера селена в http://127.0.0.1:4444/wd/hub

0 сценариев 0 шагов 0m00.000s [23:03:02] I / launcher - 0 экземпляров (ов) WebDriver все еще работают [23:03:02] I / launcher - chrome # 01 пройден

Он не обрабатывает сценарий в файле объектов и не запускает веб-страницу, определенную в файле js определения теста. Странная часть в том, что отображается тот же вывод, даже если мы изменим имя файла спецификации на «1testwithpro.feature» (так, чтобы оно не существовало). Ошибка не выдается.

Пожалуйста, дайте нам знать, что мы можем делать неправильно. Ценю вашу помощь.

1 Ответ

0 голосов
/ 05 июля 2019

Измените specs: 'testwithpro.feature' на specs: ['./testwithpro.feature']

Удалите tags в объекте cucumberOpts.

    cucumberOpts: {
      require: ['./testwithpro.js']
   },
   specs: ['./testwithpro.feature']
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...