• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript cucumber.When函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中cucumber.When函数的典型用法代码示例。如果您正苦于以下问题:TypeScript When函数的具体用法?TypeScript When怎么用?TypeScript When使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了When函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: require

const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
const expect = chai.expect;
chai.use(chaiAsPromised);

let homePage = new HomePage();
// supports/timeout.js
const { setDefaultTimeout } = require("cucumber");
let title;
let input;
let button;


setDefaultTimeout(60 * 1000);


Given(/^I Navigate to google.com$/, () => {
    browser.get("https://www.google.com/");
});

When(/^I enter something in the search bar$/, () => {
    input = element(by.xpath("//input[@title = 'Search']"));
    input.sendKeys('HELLO').then(() => {
        console.log('Value' + input.value);
        expect(input.value).to.equal('HELLO');
    });

    button = element(by.xpath("//input[@aria-label='Google Search']"));
    button.click();
});
开发者ID:winedarksea1,项目名称:ProtractorProject,代码行数:30,代码来源:homepage2.e2e-spec.ts


示例2: FormPage

// import { setWorldConstructor } from 'Cucumber';
import { expect } from 'chai';
import { Given, When, Then } from 'cucumber';
import { FormPage } from '../pages/form.po';
import { browser } from '../../node_modules/protractor';

const page = new FormPage();

Given('I am on the form', () => page.navigateTo());

When('I set my team {string}', (team) => {
  page.setTeam(team);
});

When('I set my activity {string}', (activity) => {
  page.setActivity(activity);
});

When('I set my start date {string}', (startDate) => {
  page.setStartDate(startDate);
});

When('I set my end date {string}', (endDate) => {
  page.setStartDate(endDate);
});

When('I set my status {word}', (status) => {
  page.setStatus(status);
});

When('I click on save button', () => {
开发者ID:ronerjr,项目名称:protractor-cucumber,代码行数:31,代码来源:form.steps.ts


示例3: Calculator

import { Calculator } from "../PageObjects/Calculator";
import { AngularHome } from "../PageObjects/AngularHome";

let calc = new Calculator();
let angularPage = new AngularHome();


Given('I navigate to {string} Site', async (siteUrl) => {
    await browser.manage().window().maximize();
    await browser.get(siteUrl);
});


When('I add two numbers {string} and {string}', async (num1, num2) => {

    await calc.firstTextBox.sendKeys(num1);
    await calc.secondTextBox.sendKeys(num2);
});


Then('output displayed is {string}', async (text) => {

    await calc.goButton.click();
    await calc.result.getText().then(function (repeaterText) {
        console.log("The output of Calculator addition is -> " + repeaterText);
    });
});


When('I click on header link', async () => {
开发者ID:ashutoshchittora,项目名称:TypeScriptCucumberProtractorVisualStudioCode,代码行数:30,代码来源:demoStepDefinition.ts


示例4: StepSampleWithoutDefineSupportCode

function StepSampleWithoutDefineSupportCode() {
    setWorldConstructor(function({attach, parameters}) {
        this.attach = attach;
        this.parameters = parameters;
        this.visit = (url: string, callback: Callback) => {
            callback(null, 'pending');
        };
        this.toInt = parseInt;
    });

    Before((scenarioResult: HookScenarioResult, callback: Callback) => {
        console.log(scenarioResult.result.status === Status.FAILED);
        callback();
    });

    Before({ timeout: 1000 }, (scenarioResult: HookScenarioResult, callback: Callback) => {
        console.log(scenarioResult.result.status === Status.FAILED);
        callback();
    });

    Before('@tag', (scenarioResult: HookScenarioResult, callback: Callback) => {
        console.log(scenarioResult.result.status === Status.FAILED);
        callback();
    });

    BeforeAll((callback: Callback) => {
        console.log("Before all");
        callback();
    });

    BeforeAll({ timeout: 1000 }, (callback: Callback) => {
        console.log("Before all");
        callback();
    });

    BeforeAll('@tag', (callback: Callback) => {
        console.log("Before all");
        callback();
    });

    After((scenarioResult: HookScenarioResult, callback: Callback) => {
        console.log("After");
        callback();
    });

    After({ timeout: 1000 }, (scenarioResult: HookScenarioResult, callback: Callback) => {
        console.log("After");
        callback();
    });

    After('@tag', (scenarioResult: HookScenarioResult, callback: Callback) => {
        console.log("After");
        callback();
    });

    AfterAll((callback: Callback) => {
        console.log("After all");
        callback();
    });

    AfterAll({ timeout: 1000 }, (callback: Callback) => {
        console.log("After all");
        callback();
    });

    AfterAll('@tag', (callback: Callback) => {
        console.log("After all");
        callback();
    });

    Given(/^a variable set to (\d+)$/, (x: string) => {
        console.log("the number is: " + x);
    });

    Given(/^a variable set to (\d+)$/, (x: number) => {
        console.log(typeof x);
    });

    Given(/^I am on the Cucumber.js GitHub repository$/, function(callback: Callback) {
        this.visit('https://github.com/cucumber/cucumber-js', callback);
    });

    When(/^I go to the README file$/, (title: string, callback: Callback) => {
        callback(null, 'pending');
    });

    Then(/^I should see "(.*)" as the page title$/, {timeout: 60 * 1000}, function(title: string, callback: Callback) {
        const pageTitle = this.browser.text('title');

        if (title === pageTitle) {
            callback();
        } else {
            callback(new Error("Expected to be on page with title " + title));
        }
    });

    // Type for data_table.js on
    // https://github.com/cucumber/cucumber-js/blob/a5fd8251918c278ab2e389226d165cedb44df14a/lib/cucumber/ast/data_table.js

    Given(/^a table step with Table raw$/, (table: Table) => {
//.........这里部分代码省略.........
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:101,代码来源:cucumber-tests.ts


示例5: When

import { When } from 'cucumber'
import fs from 'fs-extra'
import path from 'path'

When(
  /^(trying to execute|executing) the "([^"]+)" example$/,
  { timeout: 100000 },
  async function(tryingText, exampleName) {
    const expectError = determineExpectError(tryingText)
    await fs.copy(
      path.join('documentation', 'examples', exampleName),
      this.rootDir
    )
    await this.execute({ command: 'run', expectError })
    finish(
      expectError,
      this.process && (this.process.error || this.process.exitCode)
    )
  }
)

When(/^(trying to run|running) "([^"]*)"$/, async function(
  tryingText,
  command
) {
  const expectError = determineExpectError(tryingText)
  await this.execute({ command, cwd: this.rootDir, expectError })
  finish(expectError, this.process.error || this.process.exitCode)
})

When(/^(trying to run|running) text-run$/, async function(tryingText) {
开发者ID:Originate,项目名称:tutorial-runner,代码行数:31,代码来源:when-steps.ts


示例6: setDefaultTimeout



setDefaultTimeout(60 * 1000);

Given(/^I nagivate to the application$/, () => {
    homePage.getHomePage();
});

When(/^I land on the home page$/, () => {
    let title;
     homePage.getTitle()
    .then(data => {
        title = data;
        expect(title).to.equal('AT&T Community Forums');
        console.log(`TITLE: ${data}`);    
    })
    .catch(err => {
        console.log(`The error was ${err}`);
    });

    input = homePage.getSearchInput();
    input.sendKeys('asdfasdfasdflkjal;kejf;alskdfj');

});

Then(/^I expect homePage title to be correct$/, () => {
    // console.log(input.getSearchInput());
    console.log(input.value);

});

开发者ID:winedarksea1,项目名称:ProtractorProject,代码行数:28,代码来源:homepage.e2e-spec.ts


示例7: Given

    this.appendFile({
      path: path.join('src', barrel, 'index.js'),
      contents: `export * from './${file}';`
    })
  ]);
});

Given('I have a project', { timeout: -1 }, async function() {
  await this.createProject();
});

/**
 * When I Do
 */
When('I run beaver with {string}', function(command: string) {
  this.run(command);
});

When('I respond to the prompts with:', async function(
  questions: TableDefinition
) {
  await this.respondTo(questions.hashes() as Question[]);
});

When(
  'I wait for the command to finish with code {int}',
  { timeout: -1 },
  async function(code) {
    await this.ended();

    expect(this.output.code).to.equal(
开发者ID:valtech-nyc,项目名称:brookjs,代码行数:31,代码来源:steps.ts


示例8: require

import { browser, protractor } from "protractor";
import { SearchPageObject } from "../pages/searchPage";
const { When, Then } = require("cucumber");

const search: SearchPageObject = new SearchPageObject();

When(/^I type "(.*?)"$/, async (text) => {
    await search.searchTextBox.sendKeys(text);
});

Then(/^I click on search button$/, async () => {
    await browser.actions().sendKeys(protractor.Key.ENTER).perform();
});
开发者ID:alexrun,项目名称:protractor-cucumber-typescript,代码行数:13,代码来源:search.ts



注:本文中的cucumber.When函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript cucumber.defineSupportCode函数代码示例发布时间:2022-05-25
下一篇:
TypeScript cucumber.Then函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap