Having trouble retrieving values from a feature file in a Typescript implementation with the Cucumber Framework

Having trouble accessing values from a feature file in Typescript while using the Cucumber Framework tool Protractor. How do I retrieve these Example values in my typescript method within the When block?

Here is the code for the Feature file:

Feature: Navigate to calculator site and add two numbers

Scenario: Add two numbers using calculator site

Given I navigate to the calculator site URL "cal"

When I provide two numbers to add

Then I click on the add button on the calculator site

Scenario Outline: Provide parameters

Examples: | key1 | key2 | | 2 | 3 | | 2 | 60 |

Code snippet for the When block:

When('I provide two numbers to add', async (key1:string, key2:string) => {

// Code to input values
await cal.firstEditBox.sendKeys(key1);
await cal.secondEditBox.sendKeys(key2);

});

Upon execution, an error is encountered:

  1. Scenario: Add two numbers using calculator site # features\demo.feature:3

    √ Given I navigate to the calculator site URL "cal" # stepDefinations\steps.ts:10

    × When I provide two numbers to add # stepDefinations\steps.ts:16

    function has 2 arguments, should have 0 (if synchronous or returning a promise) or 1 (if accepting a callback)
    
    • Then I click on the add button on the calculator site # stepDefinations\steps.ts:24

    √ After # node_modules\protractor-cucumber-framework\lib\resultsCapturer.js:27

Answer №1

Feature: Utilize calculator website to perform addition
Scenario: Adding two numbers using the online calculator
Given I go to the calculator website at URL "cal"
When I input two numbers "<key1>" and "<key2>"
Then I click on the add button on the website's calculator
Scenario Outline: Providing specific parameters

Examples: 
| key1 | key2 |
| 5    |  7   |
| 10   | 20   |
When('I input two numbers {string} and {string}', async (key1:string,key2:string)=> {

// Add code here that implements the steps mentioned above

await cal.firstEditBox.sendKeys(key1);

await cal.secondEditBox.sendKeys(key2);
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with DTO and a custom decorator in NestJS

I am currently facing an issue with using a DTO alongside a custom decorator within a NestJS controller for body validation. I am sending a request using multipart/form data, which requires me to parse the data from a string to JSON. However, when attempti ...

Using TypeScript to wrap a class with a Proxy object

I've been working on a function that takes an API interface (I've provided a sample here) and creates a Proxy around it. This allows me to intercept calls to the API's methods, enabling logging, custom error handling, etc. I'm running i ...

Using Angular 2 to trigger an event when a native DOM element is loaded

I am working towards my main objective of having a textarea element automatically focused upon creation. I recently came up with an idea to use e.target.focus() on the onload event. It would look something like this: <textarea rows="8" col="60" (load)= ...

Is there a way to apply a filter to an object without using an additional map function?

When an error occurs, my pipe returns of{}. I need to filter it to redirect to other code flows. Currently, I am using the following scenario. Is there a way to remove the map and filter it within the existing filter? readonly k$ = combineLatest( [t ...

Troubleshooting the TS2559 error when using radium in React typescript: CSSProperties type mismatch

Looking to integrate Typescript into React and incorporate some styling using Radium. I understand that JSX style does not support media queries, but I'm unsure how to resolve this issue. Can anyone provide guidance? Thank you! Encountering errors w ...

What is the best way to convert JSON into a complex object in Typescript and Angular?

In my Typescript class for an Angular version 5 project, I have a JavaScript function that generates a style object. Here is the function: private createCircle(parameters: any): any { return new Circle({ radius: parameters.radius, ...

Unable to retrieve post information from Angular using PHP

I've hit a roadblock in my Angular App where I can't seem to access the body of the post data being sent from Angular 4. Despite numerous attempts, I'm unable to retrieve this crucial information. Can anyone lend a hand in identifying the is ...

Error: Angular encountered an unexpected token in the syntax

I am encountering an issue while trying to incorporate a user's profile updater on my website. Whenever I attempt to access a user's profile on the site, I run into this Angular error: main.ts:6 ERROR SyntaxError: Unexpected token 'e', ...

The error message "HighCharts Sankey + NextJS: TypeError: Unable to access property 'Core/Series/Point.js' of undefined" occurred

I am attempting to display a Sankey chart from HighCharts using the HighCharts React library within a NextJS project. I have followed the steps outlined in HighChart's documentation to integrate the Sankey module, but I encounter an error on the page: ...

Starting a line series from the beginning of the y-axis on a bar chart using chart.js

We have a new request from the business regarding the implementation of chart.js. Take a look at the image below, which shows a combination of bar and line charts. The line chart contains only a few data points. https://i.sstatic.net/mCSlR.png Within th ...

Tips for incorporating a fresh attribute into a class through a class decorator

Looking to add a new property to a class using a class decorator? Here's an example: @MyClassDecorator class MyClass { myFirstName: string; myLastName: string; } // Need to achieve something like this: function MyClassDecorator (target: any ...

Optimizing performance in React: A guide to utilizing the Context and useCallback API in child

Utilizing the Context API, I am fetching categories from an API to be used across multiple components. Given this requirement, it makes sense to leverage context for managing this data. In one of the child components, the categories can be expanded using ...

A comparison of parent and child components

To implement a child-parent component relationship in Angular, first create two JSON files: parent.json and child.json. The parent.json file should contain the following data: "Id":10001, "name":"John" "Id":10002, ...

Using the useState hook in a loop can sometimes result in a unique key error

Trying to add multiple items for rendering in my browser, but encountering an issue after clicking addItem. The item does render, however, I am getting the following error message: 'Warning: Each child in a list should have a unique ""key"" ...

Is it possible to generate one or more observables for a particular topic within a service?

After researching various sources and websites, it is apparent that there are two distinct approaches to creating a service with a subject/observable for data sharing: One approach involves initializing an observable of the subject and returning it (refer ...

Guide on updating a value in a Firestore document using Firebase

I am working on updating a specific portion of a document in my Firebase collections structure, specifically the phonebook(map) section. https://i.sstatic.net/UmHot.png When attempting to modify the document, I encountered an error saying Invalid documen ...

Unmark the checkboxes when the "Anywhere" option is selected

I need a solution in Angular that will automatically uncheck all checkboxes except for "Anywhere in the world" when that option is selected. I've tried various methods but none have worked for my specific case. What is the most straightforward way to ...

Issue with passing props to child component in React due to TypeScript error

In the process of developing an expense tracker app using react and typescript. expense_type.ts export type IState = { id : number, text : string, amount : number } export type IinitialStateType = { transactions : IState[] } expor ...

What are the typical scenarios where Angular's DI resolution modifiers are used?

Recently, I delved into the world of resolution modifiers, but I am struggling to grasp their practical application in my project. It appears that they are mainly used when dealing with services and requiring different instances of them in various parts of ...

Error message: TypeScript encountered an unexpected token '`div`' when it was expecting a jsx identifier

While working on a website using nextjs-typescript and tailwindcss, I encountered an unusual error message Expression expected. The terminal also displayed the following: Unexpected token `div`. Expected jsx identifier const UseCases = () => { 7 ...