enter code here
如果场景中没有参数,我可以运行功能文件。我得到的参数是什么?给定用户已经成功地导航到制造";DEV";应用未定义。使用以下代码段实现:
Given('User has successfully navigated to the Manufacturing {string} Application', function (string) {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
功能
登录步骤
登录页面
软件包.json
feature:
Feature: Protractor Test
@TEST
Scenario Outline: Login Test
Given User has successfully navigated to the Manufacturing "<ENV>" Application
Examples:
| ENV |
| DEV |
LoginSteps.ts
import { browser, protractor } from "protractor";
import {LoginPage} from "../pages/LoginPage";
const { When, Then , Given} = require("cucumber");
const loginpage: LoginPage = new LoginPage();
Given('User has successfully navigated to the Manufacturing (.*?) Application.', async (env) => {
await loginpage.OpenBrowser(env)
});
Loginpage.ts
import {browser, by, element, $, ElementFinder} from 'protractor';
export class LoginPage {
OpenBrowser = async (env) => {
switch (env) {
case("DEV"):
await browser.sleep(5000);
await browser.get("https://angularjs.org/");
}
}
}
enter code here
由于正则表达式,步骤定义中的步骤需要为:
Given('User has successfully navigated to the Manufacturing "(.*?)" Application.', async (env) => {
await loginpage.OpenBrowser(env)
});