本文整理汇总了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;未经允许,请勿转载。 |
请发表评论