我正在尝试建立一个自动化frameowrk来测试我的角度式Web应用程序。为此,我们将量角器与茉莉花和黄瓜一起使用。 我遇到了多个问题: 以下是package.json,我确保包括了黄瓜,硒Web驱动程序管理器的依赖项,并且确实使用以下命令安装了protractor-cucumber-framework:
npm install --save-dev protractor-cucumber-framework
package.json文件:
{
"name": "taweb",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"test-unit": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.0.2",
"@angular/cdk": "^7.0.3",
"@angular/common": "~7.0.0",
"@angular/compiler": "~7.0.0",
"@angular/core": "~7.0.0",
"@angular/forms": "~7.0.0",
"@angular/http": "~7.0.0",
"@angular/platform-browser": "~7.0.0",
"@angular/platform-browser-dynamic": "~7.0.0",
"@angular/router": "~7.0.0",
"core-js": "^2.5.4",
"font-awesome": "^4.7.0",
"ngx-logger": "^3.0.5",
"hammerjs": "^2.0.8",
"primeicons": "^1.0.0",
"primeng": "^6.1.6",
"rxjs": "~6.3.3",
"selenium-webdriver": "^4.0.0-alpha.1",
"zone.js": "~0.8.26",
"webpack": "~4.16.4",
"webpack-config": "~7.5.0",
"har-validator": "~5.1.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.10.0",
"@angular/cli": "~7.0.4",
"@angular/compiler-cli": "~7.0.0",
"@angular/language-service": "~7.0.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"codelyzer": "~4.5.0",
"cucumber": "^4.2.1",
"cucumber-html-reporter": "^4.0.3",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-firefox-launcher": "^1.1.0",
"karma-ie-launcher": "^1.0.0",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"protractor-beautiful-reporter": "^1.2.3",
"protractor-cucumber-framework": "^6.1.1",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.1"
}
}
还安装了量角器的以下插件:
-黄瓜小黄瓜完全支持
-黄瓜-gotostep
面临的问题: 1)当我创建特征文件“ test1.feature”并开始添加场景并右键单击时,它没有给我添加步骤定义的选项。仅显示与黄瓜相关的一个选项,即 “转到步骤定义”。 2)我看不到上述功能文件的黄瓜图标。不知道我在这里想念的是什么 以下是我的config.ts:
import * as path from "path";
import { browser, Config } from "protractor";
import { Reporter } from "../support/reporter";
const jsonReports = process.cwd() + "/reports/json";
export const config: Config = {
seleniumAddress: "http://127.0.0.1:4444/wd/hub",
SELENIUM_PROMISE_MANAGER: false,
baseUrl: "https://www.google.com",
capabilities: {
browserName: "chrome",
},
framework: "custom",
frameworkPath: require.resolve("protractor-cucumber-framework"),
specs: [
//"../../features/*.feature",
"src/Test/features/*.feature",
],
onPrepare: () => {
browser.ignoreSynchronization = true;
browser.manage().window().maximize();
Reporter.createDirectory(jsonReports);
},
cucumberOpts: {
compiler: "ts:ts-node/register",
format: "json:./reports/json/cucumber_report.json",
//require: ["../../typeScript/stepdefinitions/*.js", "../../typeScript/support/*.js"],
require: ["src/Test/steps/*.ts", "src/Test/support/*.ts"],
strict: true,
tags: "@CucumberScenario or @ProtractorScenario or @TypeScriptScenario or @OutlineScenario",
},
onComplete: () => {
Reporter.createHTMLReport();
},
};
3)当我尝试使用node_modules.bin \ cucumber-js“ Test1.feature”在功能文件上运行时 它显示如下:
0 scenarios
0 steps
0m00.000s
4)另外,我在以下位置也看不到webdriver manager jar文件: 当我运行命令时:
node_modules\.bin\webdriver-manager update
node_modules\.bin\webdriver-manager start
它给出错误为
events.js:167
throw er; // Unhandled 'error' event
^
Error: connect ETIMEDOUT 172.217.7.208:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
Emitted 'error' event at:
at Request.onRequestError (..\..\node_modules\request\request.js:881:8)
at ClientRequest.emit (events.js:187:15)
at TLSSocket.socketErrorListener (_http_client.js:391:9)
at TLSSocket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
如何将与webdriver-manager相关的jar文件添加为npm软件包的一部分,以便我可以更新和启动它?
非常感谢您的帮助。谢谢!
答案 0 :(得分:0)
为什么不使用量角器运行配置文件。
您已经指定了框架,硒地址,规格文件位置和功能文件位置。您应该使用量角器运行配置文件。
https://github.com/igniteram/protractor-cucumber-typescript
为避免使用webdriver-manager,请参考以下帖子。