How can I pass getSimpleRandomName () text available for all of the scenarios in a Feature file

53 views Asked by At

I got a scenario where I need to pass a random getSimpleRandomName(textType) text need to available in Feature file. I am able to get random text attached to Automation Person for scenario 1. How can I make the same text available for the rest of my scenarios?

import { Then, When, And } from "cypress-cucumber-preprocessor/steps";

Then("I type unique {string} in {string} field", (textType, textboxname) => {
  cy.getSimpleRandomName(textType).then(($value) => {
    cy.get("#content_container")
      .parent()
      .type($value);
  });
});


Feature: Create, Update
 
Background: 
  Given I open the build URL
  When I logged in as user "qa.team" 

Scenario: Create a new person
When I click on the left menu "People" > "Create New" > "Person"
And I should see "Person / New Person" page
And I type unique "Automation Person" in "* Person Name" field
Then I should see "Testing Automation Person-RedQwE" in the results table 

Scenario: Update existing person
When I click on the left menu "People" > "Open" > "Person"
And I should see "Person" page
And I type "Testing Automation Person-???" in search field  // how can I get the same text here ?
0

There are 0 answers