How to use the cucumber-tsflow.given function in cucumber-tsflow

To help you get started, we’ve selected a few cucumber-tsflow examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github samvloeberghs / protractor-gherkin-cucumberjs-angular / test / e2e / authentication / forgot-password / forgotPassword.steps.ts View on Github external
import { binding, given, when, then } from "cucumber-tsflow";
import { CallbackStepDefinition } from 'cucumber';

import { ForgotPasswordPageObject } from './forgotPassword.page';
import { LoginPageObject } from '../login';
import { AuthenticationPageObject } from '../authentication.page';

@binding()
class ForgotPasswordSteps {

  private authenticationModule = new AuthenticationPageObject();
  private loginPageObject = new LoginPageObject();
  private forgotPasswordPageObject = new ForgotPasswordPageObject();

  @given(/^user clicks the forgot password link$/)
  private givenUserClicksTheForgotPasswordLink(callback: CallbackStepDefinition) {
    this.authenticationModule.goToLoginPage();
    this.loginPageObject.navigateToForgotPasswordPage();
    callback();
  };

  @given(/^'(.*)' is the user email used in the forgot password form$/)
  private givenUserEmail(email: string, callback: CallbackStepDefinition) {
    this.forgotPasswordPageObject.setEmail(email);
    callback();
  };

  @when(/^submitting the forgot password form$/)
  private whenSubmitForm(callback: CallbackStepDefinition) {
    this.forgotPasswordPageObject.submitForm();
    callback();
github samvloeberghs / protractor-gherkin-cucumberjs-angular / test / e2e / authentication / register / register.steps.ts View on Github external
private registerPageObject = new RegisterPageObject();

  @given(/^user clicks the register link$/)
  private givenUserClicksTheLoginLink(callback: CallbackStepDefinition) {
    this.authenticationModule.goToLoginPage();
    this.loginPageObject.navigateToRegisterPage();
    callback();
  };

  @given(/^'(.*)' is the user name used in the register form$/)
  private givenUsername(name: string, callback: CallbackStepDefinition) {
    this.registerPageObject.setName(name);
    callback();
  };

  @given(/^'(.*)' is the user email used in the register form$/)
  private givenUserEmail(email: string, callback: CallbackStepDefinition) {
    this.registerPageObject.setEmail(email);
    callback();
  };

  @given(/^'(.*)' is the provided password used in the register form$/)
  private givenPassword(password: string, callback: CallbackStepDefinition) {
    this.registerPageObject.setPassword(password);
    callback();
  };

  @given(/^'(.*)' is the repeated password used in the register form/)
  private givenRepeatPassword(repeatPassword: string, callback: CallbackStepDefinition) {
    this.registerPageObject.setRepeatPassword(repeatPassword);
    callback();
  };
github 99xt / CodeSpecJS / lib / base.steps.ts View on Github external
@given(/^I read the content of element "([^"]*)" and store in variable "([^"]*)" as a "([^"]*)"$/, null, 60 * 1000)
  public readContentAndStoreInVariable(
    elementKey: string,
    variableKey: string,
    variableType: string
    ) {
    return this.readContentWithSelectionAndStoreInVariable(
      elementKey,
      null,
      null,
      variableKey,
      variableType
    );
  }

  @given(/^I read the content of element "([^"]*)" with the "([^"]*)" of "([^"]*)" and store in variable "([^"]*)" as a "([^"]*)"$/, null, 60 * 1000)
  public readContentWithSelectionAndStoreInVariable(
    elementKey: string,
    selectionMethod: string,
    selectionValue: string,
    variableKey: string,
    variableType: string
    ) {
    let elementToStore = this.getWebElement(
      elementKey,
      selectionMethod,
      selectionValue
    );
    return assert.eventually.equal(
      elementToStore.getText().then(
        (value: string) => {
          this.variableService.addVariable(variableKey, variableType, value);
github 99xt / CodeSpecJS / lib / base.steps.ts View on Github external
}

  @given(/^I Subtract variable "([^"]*)" from "([^"]*)" and store in "([^"]*)"$/, null, 60 * 1000)
  public subTractNumericValues(variableKey1: string, variableKey2: string, newVariable: string) {
    let valOne = this.getVariable(variableKey1, VariableType.Number).toNumber();
    let valTwo = this.getVariable(variableKey2, VariableType.Number).toNumber();
    const subtractVariables = () => {
      let newVal = valOne - valTwo;
      this.variableService.addVariable(newVariable, VariableType.Number, newVal.toString());
      return true;
    }
    return assert.eventually.equal(Promise.resolve(subtractVariables()), true, 'Operation failed');

  }

  @given(/^I Multiply variable "([^"]*)" from "([^"]*)" and store in "([^"]*)"$/, null, 60 * 1000)
  public multiplyNumericValues(variableKey1: string, variableKey2: string, newVariable: string) {
    let valOne = this.getVariable(variableKey1, VariableType.Number).toNumber();
    let valTwo = this.getVariable(variableKey2, VariableType.Number).toNumber();
    const multiplyVariables = () => {
      let newVal = valOne * valTwo;
      this.variableService.addVariable(newVariable, VariableType.Number, newVal.toString());
      return true;
    }
    return assert.eventually.equal(Promise.resolve(multiplyVariables()), true, 'Operation failed');

  }

  @given(/^I Divide variable "([^"]*)" from "([^"]*)" and store in "([^"]*)"$/, null, 60 * 1000)
  public divideNumericValues(variableKey1: string, variableKey2: string, newVariable: string) {
    let valOne = this.getVariable(variableKey1, VariableType.Number).toNumber();
    let valTwo = this.getVariable(variableKey2, VariableType.Number).toNumber();
github 99xt / CodeSpecJS / lib / base.steps.ts View on Github external
let waitMils = parseInt(seconds) * 1000;
    return assert.eventually.equal(
      browser.driver.sleep(waitMils).then(
        () => {
          return waitMils;
        },
        (error: any) => {
          throw new Error(error.message);
        }
      ),
      waitMils,
      'Operation failed.'
    );
  }

  @given(/^The content of "([^"]*)" has text "([^"]*)"$/, null, 60 * 1000)
  public verifyElementText(elementKey, expectedText) {
    return this.verifyElementTextWithSelectionMethod(
      elementKey,
      null,
      null,
      expectedText
    );
  }

  @given(
    /^The content of "([^"]*)" with the "([^"]*)" of "([^"]*)" has text "([^"]*)"$/,
    null,
    60 * 1000
  )
  public verifyElementTextWithSelectionMethod(
    elementKey: string,
github 99xt / CodeSpecJS / lib / base.steps.ts View on Github external
'"'
        );
      this.elementService.addNewElement(elementKey, webElement);
      return webElement;
    } else {
      let webElement = this.elementService.getElementByKey(elementKey);
      if (!webElement)
        throw new Error(
          'Element "' + elementKey + '" not found in object repository.'
        );
      return webElement;
    }
  }

  @given(/^[I|i] navigate to "([^"]*)"$/, null, 160 * 1000)
  @given(/[N|n]avigate to "([^"]*)"$/, null, 160 * 1000)
  public navigateToUrl(url: string): void {
    return assert.eventually.equal(
      browser.get(url).then(
        () => {
          return url;
        },
        (error: any) => {
          throw new Error(error.message);
        }
      ),
      url,
      'Navigated to the wrong url.'
    );
  }

  @given(/^[E|e]nter "([^"]*)" to the "([^"]*)"$/, null, 60 * 1000)
github 99xt / CodeSpecJS / lib / base.steps.ts View on Github external
true,
      'Operation failed.'
    );
  }

  @given(/^Wait for "([^"]*)" to contain text "([^"]*)"$/, null, 60 * 1000)
  public waitForElementToContainText(elementKey: string, targetText: string) {
    return this.waitForElementToContainTextWithSelection(
      elementKey,
      null,
      null,
      targetText
    );
  }

  @given(
    /^Wait for "([^"]*)" with the "([^"]*)" of "([^"]*)" to contain text "([^"]*)"$/,
    null,
    60 * 1000
  )
  public waitForElementToContainTextWithSelection(
    elementKey: string,
    selectionMethod: string,
    selectionValue: string,
    targetText: string
    ) {
    let elementToWait = this.getWebElement(
      elementKey,
      selectionMethod,
      selectionValue
    );
    let expectedCondition = ExpectedConditions.textToBePresentInElement(
github 99xt / CodeSpecJS / lib / base.steps.ts View on Github external
},
        (error: any) => {
          throw new Error(error.message);
        }
      ),
      true,
      'This had better be true, eventually'
    );
  }

  @given(/^Click on "([^"]*)"$/, null, 60 * 1000)
  public clickOnElement(elementKey) {
    this.clickOnElementWithSelectionMethod(elementKey, null, null);
  }

  @given(
    /^Click on "([^"]*)" with the "([^"]*)" of "([^"]*)"$/,
    null,
    60 * 1000
  )
  public clickOnElementWithSelectionMethod(
    elementKey,
    selectionMethod,
    selectionValue
    ) {
    let elementToClick = this.getWebElement(
      elementKey,
      selectionMethod,
      selectionValue
    );
    return assert.eventually.equal(
      elementToClick.click().then(
github 99xt / CodeSpecJS / lib / base.steps.ts View on Github external
'Navigated to the wrong url.'
    );
  }

  @given(/^[E|e]nter "([^"]*)" to the "([^"]*)"$/, null, 60 * 1000)
  @given(/^[I|i] enter "([^"]*)" to the "([^"]*)"$/, null, 60 * 1000)
  public enterTextToElement(inputValue: string, elementKey: string) {
    this.enterTextToElementWithSelectionMethod(
      inputValue,
      elementKey,
      null,
      null
    );
  }

  @given(
    /^I enter "([^"]*)" to the "([^"]*)" with the "([^"]*)" of "([^"]*)"$/,
    null,
    60 * 1000
  )
  public enterTextToElementWithSelectionMethod(
    inputValue: string,
    elementKey: string,
    selectionMethod: string,
    selectionValue: string
    ) {
    let inputElement = this.getWebElement(
      elementKey,
      selectionMethod,
      selectionValue
    );
github 99xt / CodeSpecJS / lib / base.steps.ts View on Github external
return assert.eventually.equal(
      inputElement.sendKeys(inputValue).then(
        () => {
          return true;
        },
        (error: any) => {
          throw new Error(error.message);
        }
      ),
      true,
      'This had better be true, eventually'
    );
  }

  @given(/^Click on "([^"]*)"$/, null, 60 * 1000)
  public clickOnElement(elementKey) {
    this.clickOnElementWithSelectionMethod(elementKey, null, null);
  }

  @given(
    /^Click on "([^"]*)" with the "([^"]*)" of "([^"]*)"$/,
    null,
    60 * 1000
  )
  public clickOnElementWithSelectionMethod(
    elementKey,
    selectionMethod,
    selectionValue
    ) {
    let elementToClick = this.getWebElement(
      elementKey,

cucumber-tsflow

Provides 'specflow' like bindings for CucumberJS 7.0.0+ in TypeScript 1.7+.

MIT
Latest version published 7 months ago

Package Health Score

70 / 100
Full package analysis