當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript cucumber.Given函數代碼示例

本文整理匯總了TypeScript中cucumber.Given函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript Given函數的具體用法?TypeScript Given怎麽用?TypeScript Given使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Given函數的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 { browser, by, element } from "protractor";
import { Given, When, Then } from "cucumber";
import { async } from "q";
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);
    });
});
開發者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: require

import { browser } from "protractor";
import { SearchPageObject } from "../pages/searchPage";
const { Given } = require("cucumber");
const chai = require("chai").use(require("chai-as-promised"));
const expect = chai.expect;

const search: SearchPageObject = new SearchPageObject();

Given(/^I am on google page$/, async () => {
    await expect(browser.getTitle()).to.eventually.equal("Google");
});

Given(/^I am on cucumber search results page$/, async () => {
    await expect(browser.getTitle()).to.eventually.equal("Cucumber - Google Search");
});

Given(/^I am on protractor search results page$/, async () => {
    await expect(browser.getTitle()).to.eventually.equal("Protractor - Google Search");
});
開發者ID:alexrun,項目名稱:protractor-cucumber-typescript,代碼行數:19,代碼來源:homePage.ts

示例6: Given

import { Given } from 'cucumber'
import fs from 'fs-extra'
import mkdirp from 'mkdirp'
import path from 'path'
import { cp } from 'shelljs'

Given('a broken file {string}', async function(filePath) {
  const subdir = path.dirname(filePath)
  if (subdir !== '.') {
    mkdirp.sync(path.join(this.rootDir, subdir))
  }
  await fs.writeFile(
    path.join(this.rootDir, filePath),
    `
      <a href="missing">
      </a>
      `
  )
})

Given('a runnable file {string}', async function(filePath) {
  const subdir = path.dirname(filePath)
  if (subdir !== '.') {
    const subdirPath = path.join(this.rootDir, subdir)
    let subdirExists = false
    try {
      await fs.stat(subdirPath)
      subdirExists = true
    } catch (e) {
      // nothing to do here
    }
開發者ID:Originate,項目名稱:tutorial-runner,代碼行數:31,代碼來源:given-steps.ts

示例7: 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;


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();
開發者ID:winedarksea1,項目名稱:ProtractorProject,代碼行數:31,代碼來源:homepage.e2e-spec.ts

示例8: Before

Before(function(testCase) {
  const { name } = testCase.pickle;

  this.snapshot.testname = name;
  this.snapshot.filename = `features/__snaps__/${name
    .toLowerCase()
    .replace(/\s/g, '-')}.snap`;
});

/**
 * Given I Have
 */
Given('I have project with {string}', async function(type: string) {
  await this.createProjectWith([
    {
      path: `src/${type}/index.js`,
      contents: ''
    }
  ]);
});

Given('I have a file called {string} exported from {string}', async function(
  file: string,
  barrel: string
) {
  await Promise.all([
    this.outputFile({ path: path.join('src', barrel, file), contents: '' }),
    this.appendFile({
      path: path.join('src', barrel, 'index.js'),
      contents: `export * from './${file}';`
    })
  ]);
開發者ID:valtech-nyc,項目名稱:brookjs,代碼行數:32,代碼來源:steps.ts


注:本文中的cucumber.Given函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。