In this scenario, we cannot hard-code a single email to test because it may lead to a 409 Conflict error because an account with that email already exists. Therefore, we need to generate a random email each time the test is run. We need to define a new step definition where the data is randomly generated each time:
When(/^user types in an? (in)?valid (\w+) in the (?:"|')([\.#\w-]+)(?:"|') element$/, async function (invalid, type, selector) { const textToInput = generateSampleData(type, !invalid); this.element = await this.driver.findElement(By.css(selector)); return this.element.sendKeys(textToInput);});
Here, we create a generic step definition and use the yet-to-be-defined generateSampleData function to provide the ...