In my feature file, I have the following scenario outlined for testing colors:
Feature: Color feature
@test
Scenario Outline: Test color
Given the first color is <COLOR_ONE>
And the second color is <COLOR_TWO>
When the user loads page
Then the <COLOR_THREE> is displayed
Examples:
| COLOR_ONE | COLOR_TWO | COLOR_THREE
| red | white | pink
| blue | black | black
| green | purple | white
I am struggling to create an efficient step file. Every time I run protractor, it generates code for each scenario separately. How can I simplify this process by just creating two Given
steps that handle variables passed to the function? The same applies to the Then
step.
Even with my TypeScript attempts below, the automation framework still requires me to write individual steps for all variations, resulting in failed tests.
import { browser, element, by } from 'protractor';
const { Given, When, Then, defineSupportCode } = require('cucumber');
defineSupportCode(function ({ setDefaultTimeout }) {
setDefaultTimeout(120 * 1000);
});
Given(/^ the first color is "([^"]*)" $/, (color, next) => {
next();
});
Given(/^ the second color is "([^"]*)" $/, (color, next) => {
next();
});
When(/^ the user loads page $/, (next) => {
next();
});
Then(/^ the "([^"]*)" is displayed $/, (color, next) => {
next();
});